Introspection Question: Determining subclass name in base class

Discussion in 'Python' started by Stephen Nesbitt, Nov 22, 2004.

  1. 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
     
    Stephen Nesbitt, Nov 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jstorta
    Replies:
    3
    Views:
    475
    jstorta
    Feb 20, 2006
  2. Mark English
    Replies:
    9
    Views:
    392
    Mike C. Fletcher
    Jan 22, 2005
  3. *binarystar*

    Introspection Class/Instance Name

    *binarystar*, Apr 26, 2006, in forum: Python
    Replies:
    4
    Views:
    369
    robert
    Apr 26, 2006
  4. S.Volkov
    Replies:
    2
    Views:
    242
    S.Volkov
    Mar 12, 2006
  5. Trans
    Replies:
    8
    Views:
    352
    Robert Klemme
    Oct 23, 2008
Loading...

Share This Page