Can't refer to base class attribute?

mrstephengross mrstephengross at
Tue Oct 23 20:54:06 CEST 2007

I've got a Base class with an attribute "foo" (of type Foo), and a
Derived class (derived from Base). In Derived's constructor, I try to
refer to, but python complains:
  AttributeError: class Base has no attribute 'foo'

Any ideas? (code below)

=== CODE ===

class Foo:
  def __init__ (self):
    self.x = 3

class Base:
  def __init__ (self): = Foo()

class Derived(Base):
  def __init__(self):
    Base.__init__(self) = 5

=== EOF ===

More information about the Python-list mailing list