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?

有帮助吗?

解决方案

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

其他提示

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'
>>> 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top