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




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
.



Relevant Pages

  • Re: Auto Warehousing Co. switching to Macs
    ... he noticed that Apple is much, ... That solves the legacy problem, ... that consumers need to upgrade to the new package. ...
    (comp.sys.mac.advocacy)
  • Re: The naming of at()s is a difficult matter
    ... Solaris decisions... ... It's hardly a hardship to maintain the legacy names for backwards compatibility; since those names are nonsensical it is unlikely they'll ever want to be claimed, in which case they can be maintained indefinitely. ...
    (Linux-Kernel)
  • Mixed C++ assembly
    ... I am developing managed C++ wrapper for legacy C++ code. ... Changed settings to make it mixed assembly ... Created managed wrappers for legacy classes in separate namespace ...
    (microsoft.public.dotnet.framework.interop)