Forward References?
Fredrik Lundh
effbot at telia.com
Tue Apr 18 07:55:23 EDT 2000
More information about the Python-list mailing list
Tue Apr 18 07:55:23 EDT 2000
- Previous message (by thread): Forward References?
- Next message (by thread): Forward References?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jerome Chan <eviltofu at rocketmail.com> wrote: > > > class a: > > > def x(self): > > > y(self) > > > def y(self): > > > print "Hello" > > > > > > c = a() > > > c.x() > > > c.y() > > > > > > gives a NameError: y > > > > Your mistake isn;t what you think it is, try this instead: > > > > class a: > > def x(self): > > self.y() > > def y(self): > > print "Hello" > > > > HTH, HAND, > > M. > > Thanks! I also found out that > > a.y() works! really? Traceback (most recent call last): File "broken.py", line 8, in ? File "broken.py", line 3, in x TypeError: unbound method must be called with class instance 1st argument but maybe you meant "a.y(self)"? it's not the same thing, and breaks down the day you start to use inheritance. as usual, python works best if you use it to write python code... </F>
- Previous message (by thread): Forward References?
- Next message (by thread): Forward References?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list