473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

list property fires get on append

ian
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.

Here's a stripped down version of my code:

class Hierarchy(object):
_children = []

def __init__(self):
return

def get_children(self):
print("GETTING")
return self._children

def set_children(self, value):
print("SETTING")
self._children = value

children = property(get_children, set_children)

-----USAGE------

import Hierarchy
hierarchy = Hierarchy.Hierarchy()
# this fires a get for some reason
hierarchy.children.append( Hierarchy.Hierarchy())
# this fires a set as expected
hierarchy.children = [Hierarchy.Hierarchy()]

------RESULT------

it prints:

GETTING
SETTING
Jan 6 '08 #1
0 844

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Martin Christensen | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Howdy! Suppose I have a list A containing elements that I want to put into list B if they satisfy some property. The obvious way of doing it...
1
by: Chicken Kebab Abdullah | last post by:
I am making a database of my movie collection and I have a form which Shows a DVD Code in a combo, and a list of the divx movies on the dvd on the right in a list box. The combo boxes bound...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
1
by: Timo | last post by:
I am trying to use the DropDownList_SelectedIndexChanged event on a dropdown which is dynamically populated with different values at runtime, depending on what the user has been doing. The dropdown...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
0
by: Scott K | last post by:
I have a datalist which has an edititem template. When the user is in edit mode (of the datalist) it shows a couple of text boxes for editing as well as a drop down list box and has a label...
7
by: Lonnie Princehouse | last post by:
Here's a curious hack I want to put up for discussion. I'm thinking of writing a PEP for it. Observation ----------------- I found myself using this construct for assembling multiple lists: ...
1
by: David Veeneman | last post by:
This posting is for the Google crawler and requires no response. I have created a multi-level object hierarchy, in which the root object needs to be notified whenever any property of any object...
2
by: Lespaul36 | last post by:
I have a control that I have made that uses a custom class for storage of some of the information. I want it to display in the VS.Net 2003 property grid in the IDE like the Font property does, so...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.