Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
Created April 7, 2014 16:52
Show Gist options
  • Save alanbriolat/10024028 to your computer and use it in GitHub Desktop.
Save alanbriolat/10024028 to your computer and use it in GitHub Desktop.
import logging
logging.basicConfig(level=logging.DEBUG)
class Foo(object):
def __init__(self):
self.bar = "hello"
def __getitem__(self, key):
return getattr(self, key)
f = Foo()
# Outputs "DEBUG:root:hello"
logging.debug("%(bar)s" % f)
# Raises "TypeErorr: format requires a mapping"
logging.debug("%(bar)s", f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment