instance method questions

Frederick Polgardy sentientholon at gmail.com
Wed Aug 22 11:51:18 EDT 2007


On Aug 22, 10:23 am, Danny <shev... at lanl.gov> wrote:
> 1) how do I dynamically inspect an object to determine if it has an instance
> method? (there is a class method with the same name)

class Foo:
    def foo(self):
        pass

x = Foo()

import types

>>> isinstance(x.foo, types.MethodType)
True

> 2) how do I dynamically delete the instance method?

>From the instance?  You can't, you have to delete it from the class:

>>> del Foo.foo




More information about the Python-list mailing list