Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Introspection Question: Determining subclass name in base class

Thread Tools

Introspection Question: Determining subclass name in base class

Stephen Nesbitt
Posts: n/a

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
206.219.8271 Removed)
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
subclass a class in the namespace of the that subclass Trans Ruby 8 10-23-2008 07:24 AM
Introspection Class/Instance Name *binarystar* Python 4 04-26-2006 12:38 PM
String subclass method returns subclass - bug or feature? S.Volkov Ruby 2 03-12-2006 06:46 PM
subclass has a variable that is subclass of same superclass jstorta Java 3 02-20-2006 08:42 PM
Class introspection and dynamically determining function arguments Mark English Python 9 01-22-2005 06:44 PM