Re: Does altering a private member decouple the property's value?
- From: Jay Loden <jloden@xxxxxxxxxxxx>
- Date: Tue, 19 Jun 2007 00:52:41 -0400
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
.
- References:
- Does altering a private member decouple the property's value?
- From: Ethan Kennerly
- Re: Does altering a private member decouple the property's value?
- From: Alex Martelli
- Does altering a private member decouple the property's value?
- Prev by Date: Re: HTMLParser.HTMLParseError: EOF in middle of construct
- Next by Date: Re: sizeof() in python
- Previous by thread: Re: Does altering a private member decouple the property's value?
- Next by thread: Re: Does altering a private member decouple the property's value?
- Index(es):
Relevant Pages
|