where does __class__ come from?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • patrick.m.lahey@aero.org

    #1

    where does __class__ come from?

    Newbie here...

    Ok, the following code:

    class Base:
    _count = 0
    def __init__(self):
    self.__class__. _count += 1
    print dir(self)

    x = Base()

    the output is:

    ['__doc__', '__init__', '__module__', '_count']

    Notice that __class__ is no where to be seen!

    Where does __class__ come from, what does it mean and what else is
    being hidden?

    I am used to using dir(...) to figure out what I can play with.
    Clearly that does not always work... :-(

    Thanks!

  • wittempj@hotmail.com

    #2
    Re: where does __class__ come from?

    see http://docs.python.org/lib/specialattrs.html

    Comment

    • Diez B. Roggisch

      #3
      Re: where does __class__ come from?

      > Where does __class__ come from, what does it mean and what else is[color=blue]
      > being hidden?
      >
      > I am used to using dir(...) to figure out what I can play with.
      > Clearly that does not always work... :-([/color]

      Your question has benn answered - let me just add this from the dir()-docs:

      Note: Because dir() is supplied primarily as a convenience for use at
      an interactive prompt, it tries to supply an interesting set of names
      more than it tries to supply a rigorously or consistently defined set
      of names, and its detailed behavior may change across releases.

      from



      Regards,

      Diez

      Comment

      Working...