Getty fully qualified class name from class object

Ian Pilcher arequipeno at gmail.com
Tue Aug 22 10:45:05 EDT 2023


How can I programmatically get the fully qualified name of a class from
its class object?  (I'm referring to the name that is shown when str()
or repr() is called on the class object.)

Neither the __name__ or __qualname__ class attributes include the
module.  For example:

   >>> import logging

   >>> str(logging.Handler)
   "<class 'logging.Handler'>"

   >>> logging.Handler.__name__
   'Handler'
   >>> logging.Handler.__qualname__
   'Handler'

How can I programmatically get 'logging.Handler' from the class object?

-- 
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================


More information about the Python-list mailing list