list property fires get on append
Soviut
ian at neustyle.com
Sun Jan 6 03:31:13 EST 2008
On Jan 6, 3:03 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> i... 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>
I figured that an append would be treated as a set since I'm adding to
the list. But what you say makes sense, although I can't say I'm
happy with the behaviour. Is there any way I can get the append to
fire a set? I'm thinking of properties from my C# background where i
believe that manipulation such this would be considered a set.
More information about the Python-list
mailing list