Using properties

Terry Reedy tjreedy at udel.edu
Wed May 25 15:19:56 EDT 2005


<tkpmep at hotmail.com> wrote in message 
news:1117041254.820429.306500 at g49g2000cwa.googlegroups.com...
> Thanks for the help. I now understand it better. As Bruno points out, I
> really don't need a property in this case, as my attribute is public,
> and I will remove it.

As much to the point is that your name attribute is static in the sense of 
being a fixed object between settings.  Should you later want to make it 
dynamic (or perhaps lazy) in the sense of being computed on demand, then 
you can do so with property() *without* changing the external interface to 
the class.

A third reason for property() is when you want to do something in addition 
to the access, such as reporting the access to something else.

Terry J. Reedy






More information about the Python-list mailing list