deleting a method

MRAB google at mrabarnett.plus.com
Sat Jan 3 23:36:47 CET 2009


Filip Gruszczyński wrote:
> I am trying to delete a method from a class. It's easy to delete other
> attributes, but when I try:
> 
>>>> class A:
> ...     def foo():
> ...             pass
> ...
>>>> a = A()
>>>> del a.foo
> 
> I get
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: A instance has no attribute 'foo'
> 
> Why is it so and how may still delete it?
> 
'a' is an instance of class A. You're trying to delete 'foo' from the 
instance.



More information about the Python-list mailing list