Runtime check of methods
meowing at banet.net
Mon Aug 23 19:34:02 CEST 1999
Per Kistler <kistler at fnmail.com> wrote:
> Why does Python only runtime check, wether it knows a method? For
> instance, if I forget to put the "self." in front of a method in a
> class, than python myclass.py still does not complain.
It's not necessarily an error. Remember that this language treats
everything as a big pile of function pointers and dispatch tables, and
you can mess around with them at run time. Try this:
=-=-=-= goofymod.py =-=-=-=
print unknownsub() # This doesn't look at all healthy.
=-=-=-= main.py =-=-=-=
foo = goofymod.Goofyclass() # We still have no unknownsub,
goofymod.unknownsub = useful # but fix that here,
foo.doit() # and it even works.
More information about the Python-list