Does altering a private member decouple the property's value?

Jay Loden jloden at jayloden.com
Tue Jun 19 00:52:41 EDT 2007


Alex Martelli wrote:
>
>>>>> class a_class:
> 
> This is ALL of the problem: you're using a legacy (old-style) class, and
> properties (particularly setters) don't work right on its instances (and
> cannot, for backwards compatibility: legacy classes exist exclusively to
> keep backwards compatibility with Python code written many, many years
> ago and should be avoided in new code).
> 
> Change that one line to
> 
> class a_class(object):
> 
> and everything else should be fine.  If you want, I can try to explain
> the why's and wherefore's of the problem, but to understand it requires
> deeper knowledge of Python than you'll need for just about any practical
> use of it: just retain the tidbit "NEVER use oldstyle classes" and you
> won't need to understand WHY you shouldn't use them:-).

Can you elaborate (or just point me to a good doc) on what you mean by an "old style" class versus the new style? I learned Python (well, am still learning) from an older book, and I just want to make sure that I'm using the preferred method.

Thanks, 

-Jay



More information about the Python-list mailing list