Introspection Question: Determining subclass name in base class

Stephen Nesbitt snesbitt at cobaltgroup.com
Mon Nov 22 18:00:46 EST 2004


All:

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?

Thanks!

-steve
-- 

Stephen Nesbitt
Senior Configuration Management Engineer
The Cobalt Group
206.219.8271
snesbitt at cobaltgroup.com



More information about the Python-list mailing list