class-call a function in a function -problem
steven.bethard at gmail.com
Tue Aug 16 19:47:02 CEST 2005
> class ludzik:
> def l(self):
> print ludzik.l
> def ala(self):
> print ludzik.x
> print ludzik.y
Methods defined in a class expect an instance of that class as the first
argument. When you write:
you are not passing any instance to the l() method. Instead you should
Note that "self.l()" gets translated into the equivalent of
"ludzik.l(self)" internally in Python. That is, the method ludzik.l
gets called with "self" as the first parameter.
In general, I'd be surprised if you really want all those "ludzik.XXX"
attribute accesses. I'd expect that most of those should really be
"self.XXX" accesses. You want to modify the instance (called "self" in
your methods), not the class (called "ludzik" in your example).
More information about the Python-list