Forward References?
Michael Hudson
mwh21 at cam.ac.uk
Mon Apr 17 22:04:35 EDT 2000
Jerome Chan <eviltofu at rocketmail.com> writes:
> Just a silly question but how do I do forward references?
>
>
> 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.
--
112. Computer Science is embarrassed by the computer.
-- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html
More information about the Python-list
mailing list