Anomaly in creating class methods
aleax at mail.comcast.net
Fri Nov 4 06:34:22 CET 2005
venk <venkatasubramanian at gmail.com> wrote:
> given below is my interaction with the interpreter.... In one case, i
> have created the class method using the "famous idiom"... and in the
> other, i have tried to create it outside the class definition... why
> isn't the latter working ? (of course, the presence of decorators is a
> different issue)....
When you access D.f, you get an unbound method; if you want the
underlying function instead, use D.f.im_func. When you access f within
the class's body, you do get the underlying function -- that's all of
the difference that's biting you...
More information about the Python-list