list property fires get on append

Fredrik Lundh fredrik at pythonware.com
Sun Jan 6 09:03:59 CET 2008


ian at neustyle.com wrote:

> I've created a class that has a property which points at a private
> list.  When I try to use the append() function on this list property,
> the fget method is fired rather than the fset method.  If I directly
> set my property to a literal list, the set method fires.

> # this fires a get for some reason
> hierarchy.children.append( Hierarchy.Hierarchy())

that's the expected behaviour: you're *fetching* the "children" 
attribute in order to modify it, you're not replacing it.

reading up on Python's object model might be helpful.

</F>




More information about the Python-list mailing list