>>>>> dasacc22 <dasac...@gmail.com> (d) wrote:

>d> Ah thank you for clarifying, I did confuse instance and class
>d> attributes from creating the list in the class def. I actually just
>d> spiffed up that class to represent a portion of a much larger class
>d> that needs getter and setter for children. Doing as you said fixed my
>d> problem, heres the code as reference for w/e

>d> class Widget(object):
>d>     _children = None
>d>     _parent = None

You still have them as class variables here. Now they are only used as
defaults because you assign to them in the instances so the instance
variables will be created then. But I think it is still confusing to
have these class variables here that you never use as such. Maybe this
is some leftover from Java experience where you do declare instance
variables at the class level?

>d>     def __init__(self, parent=None):
>d>         self.children = []
>d>         self.parent = parent

>d>     @property
>d>     def children(self):
>d>         return self._children

>d>     @children.setter
>d>     def children(self, obj):
>d>         self._children = obj

What is the added value of using a property for the children attribute?
Why not just use an instance variable directly? Also a Java inheritance?

-- 
Piet van Oostrum <p...@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to