Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    This appears to return the module where bar was defined, not where Bar was defined. If the purpose of logging is to know exactly what kind of object it was, then this doesn't seem to help. Commented May 24, 2012 at 14:45
  • Is o.__class__.__module__ ever different from o.__module__? Commented Feb 18, 2014 at 19:07
  • 4
    larsks: yes it is, stackoverflow.com/questions/5271112/… Commented Apr 4, 2015 at 21:17
  • 5
    I strongly recomend ".".join([o.__module__, o.__name__]) for Python3 Commented Nov 29, 2017 at 15:35
  • Doesn't work sometimes: AttributeError: 'AttributeError' object has no attribute '__module__' Commented Jul 23, 2018 at 9:28