It's not a Python file, but a logging configuration file. See logging config file format.
Can someone explain this Python syntax?
質問
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?
解決
他のヒント
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'
>>>
所属していません StackOverflow