Question

I am working with Pyramid for Python and there are several files that have the syntax below. I'm very new to Python, and none of the 3 books I have read so far mention this format.

[logger_sqlalchemy]
level = INFO
handlers =
qualname = sqlalchemy.engine

My guess is that it's a way of creating a list named logger_sqlalchemy.

logger_sqlalchemy = [level:INFO, handlers:'', qualname:sqlalchemy]

Is this what the code is doing?

Was it helpful?

Solution

It's not a Python file, but a logging configuration file. See logging config file format.

OTHER TIPS

That syntax appears to be completely off. However, if you appear to have ascertained it correctly, it would not be a list, because that raises a SyntaxError:

>>> logger_sqlalchemy = ['level':'INFO', 'handlers':'', 'qualname':'sqlalchemy'] 
  File "<stdin>", line 1
    logger_sqlalchemy = ['level':'INFO', 'handlers':'', 'qualname':'sqlalchemy']
                                ^
SyntaxError: invalid syntax

Instead, it would be a dictionary:

>>> logger_sqlalchemy = {'level':'INFO', 'handlers':'', 'qualname':'sqlalchemy'} 
>>> logger_sqlalchemy['handlers']
''
>>> logger_sqlalchemy['level']
'INFO'
>>> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top