Introspection Question: Determining subclass name in base class

Stephen Nesbitt snesbitt at
Tue Nov 23 00:00:46 CET 2004


Here's my implementation problem. I have a base class which has the 
responsibility for providing entry into the logging system. Part of 
the class responsibility is to ensure that lagger names are 
consistent. For all intents and purposes this class should be 
considered abstract and will always be subclassed.

What I want to do is the following:
- allow the logger name to set explicitly. I've accomplished this by 
adding a loggerName parameter to __init__ in the base class.
- if the loggerName variable is None, then set it to the name of the 
subclass for which we are initing.

There seem to be two issues here.
1) determining the subclass name inside the _init__method in the 
abstract base class. All my efforts so far have resulted in the 
name of the base class rather than the calling subclass.

2) setting the default of a parameter to a function.

Can anyone help?



Stephen Nesbitt
Senior Configuration Management Engineer
The Cobalt Group
snesbitt at

More information about the Python-list mailing list