Overriding a global

Joshua Landau joshua.landau.ws at gmail.com
Mon Dec 12 16:47:23 EST 2011


Wouldn't this be nicer, though?:

def getChildLogger(id):
    return logger.getChild(id)

def someFunc():
    logger = getChildLogger("someFunc")


-- UNTESTED --

No messing around with globals this way, and it's more extendable. And
'globals()["logger"].getChild("someFunc")' reads like a brick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111212/a03d447d/attachment.html>


More information about the Python-list mailing list