Can't refer to base class attribute?
- From: mrstephengross <mrstephengross@xxxxxxxxxxx>
- Date: Tue, 23 Oct 2007 18:54:06 -0000
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 Base.foo, but python complains:
AttributeError: class Base has no attribute 'foo'
Any ideas? (code below)
=== CODE ===
#!/usr/bin/python
class Foo:
def __init__ (self):
self.x = 3
class Base:
def __init__ (self):
self.foo = Foo()
class Derived(Base):
def __init__(self):
Base.__init__(self)
Base.foo.x = 5
Derived()
=== EOF ===
.
- Follow-Ups:
- Re: Can't refer to base class attribute?
- From: Marc 'BlackJack' Rintsch
- Re: Can't refer to base class attribute?
- Prev by Date: Re: Python - why don't this script work?
- Next by Date: Re: New module for method level access modifiers
- Previous by thread: tracking/ordering log files
- Next by thread: Re: Can't refer to base class attribute?
- Index(es):
Relevant Pages
|