Immutability

Fredrik Lundh fredrik at pythonware.com
Wed Jun 28 11:31:51 EDT 2006


Nick Maclaren wrote:

> class fred :
>    @property
>    def joe (self) :
>        print "Inside /joe\n"
>
> a = fred()
> a.joe()
>
> Traceback (most recent call last):
>  File "crap.py", line 14, in <module>
>    a.joe()
> TypeError: 'NoneType' object is not callable
>
> VERY weird - I could understand it if I got the error and DIDN'T succeed
> in the call ....

a property looks like an attribute, not a method, so you're trying to call whatever
your "joe()" method returns.

(that's what "a function for getting an attribute value" in the property documentation
refers to).

</F> 






More information about the Python-list mailing list