dworkin at ccs.neu.edu
Wed Apr 19 00:53:14 CEST 2000
"Jeff Massung" <jmassung at magpiesystems.com> writes:
> >class a:
> > def x(self):
> > y(self)
> Should this be a.y(self)?
No, it should be self.y()
It could be a.y(self), and that would work for many cases, but that
isn't really what you want.
> Also, someone mentioned above having: self.y() (or self.y(self)), my
> question is what is the difference between a.y and self.y?
It's easy to find out in the interactive interpreter.
>>> class a:
... def y(self):
... print 1
>>> b = a()
<unbound method a.y>
<method a.y of a instance at 80a67e8>
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: unbound method must be called with class instance 1st
Or, of course, one could read the documentation or tutorial. This is
pretty well explained, iirc.
More information about the Python-list