function as attr of subclass != method (???)

homunq at my-deja.com homunq at my-deja.com
Thu Nov 25 07:53:36 CET 1999


I'm confused by the following. Is it a bug, or is something subtle going
on that I should understand?

>>> class parent:
	pass


>>> class child(parent):
	pass


>>> achild = child()
>>> parent.method = lambda self:"yup"
>>> achild.method()
'yup'
>>> achild.method = lambda self:"nope"
>>> achild.method()
Traceback (innermost last):
  File "<pyshell#102>", line 1, in ?
    achild.method()
TypeError: not enough arguments; expected 1, got 0


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list