[Python-au] New Python Class Features
Fri, 17 Jan 2003 15:23:59 +1100
And you can have the best of both worlds by using an object's __dict__, and
the associated __getattr__ and __setattr__
Eg, bunch object for setting a whole bunch of properties from keyword args:
>>> Brian White <email@example.com> 17/01/2003 15:07:09 >>>
At 15:04 17/01/2003, Andrew Bennetts wrote:
>I'd recommend only using property for computed attributes (i.e. ones that
>need a function call to calculate their value). Most of the time you don't
> > What I am trying to determine if their is a short way as this is going to
> > take ages when writing an object that has 20 properties
>Just use the simplest thing that works -- accessing the attributes directly.
>Is there any particular reason why you wanted to use properties?
In one sense it depends on how much of a purist you are!
Using Get/Set methods means that at any time you can
change the underlying storage or trigger events off the
Get and Set
Maybe it depends how far up the hierachy your class is...
Step Two Designs Pty Ltd
Knowledge Management Consultancy, SGML & XML
Content Management Requirements Toolkit
112 CMS requirements, ready to cut-and-paste
python-au maillist - firstname.lastname@example.org