Created
July 29, 2019 15:43
-
-
Save clbarnes/edd28ea32010eb159b34b075687bb49e to your computer and use it in GitHub Desktop.
Get the fully-qualified class name of a python object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def classname(obj): | |
cls = type(obj) | |
module = cls.__module__ | |
name = cls.__qualname__ | |
if module is not None and module != "__builtin__": | |
name = module + "." + name | |
return name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing!