Why does this python code work?

Posted by Int-0 on Stack Overflow See other posts from Stack Overflow or by Int-0
Published on 2011-11-23T17:41:57Z Indexed on 2011/11/23 17:50 UTC
Read the original article Hit count: 204

Filed under:
|
|
|

I have written a simple python module, it has this code:

_log = logging.getLogger("mymodule")
_started = False

def set_log_level(level):
    _log.setLevel(level)
    if not _started:
        _hdlr = logging.FileHandler('mymodule.log')

When I call set_log_level() program fails because symbol _started is not found. It is normal because global _started is missing in the method. But my question is: symbol _log has the same visibility as _started, so why does this symbol can be found?

BR,

// Toby

© Stack Overflow or respective owner

Related posts about python

Related posts about module