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

2007-06-22 Thread Bruno Desthuilliers
Ethan Kennerly a écrit : > Thanks for the help! Using the "class name (object)" syntax fixed my > problem. > (snip) > > I am having to unteach myself some of the defensive programming techniques > in C++, such as using name mangling to ensure privacy, when privacy is not > the most important cri

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

2007-06-22 Thread Ethan Kennerly
Thanks for the help! Using the "class name (object)" syntax fixed my problem. Usually, I don't need properties, but in the case of a dependent attribute, I used a set method of a property to update that dependent attribute. I have a stopwatch class with a time limit property. When the time limi

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

2007-06-20 Thread Bruno Desthuilliers
Ethan Kennerly a écrit : > Hello, > > There are a lot of Python mailing lists. I hope this is an appropriate one > for a question on properties. It is. > I am relatively inexperienced user of Python. I came to it to prototype > concepts for videogames. Having programmed in C, scripted in Uni

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

2007-06-20 Thread Bruno Desthuilliers
Ben Finney a écrit : > "Ethan Kennerly" <[EMAIL PROTECTED]> writes: > >> I really like properties for readonly attributes, > > Python doesn't have "readonly attributes", Err... Ever tried to set a class mro ?-) > and to attempt to use > properties for that purpose will only lead to confusion.

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

2007-06-19 Thread Alex Martelli
Ben Finney <[EMAIL PROTECTED]> wrote: > "Ethan Kennerly" <[EMAIL PROTECTED]> writes: > > > I really like properties for readonly attributes, > > Python doesn't have "readonly attributes", Many Python types do, e.g.: >>> def f(): pass ... >>> def g(): pass ... >>> f.func_name = 'zap' >>> f.f

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

2007-06-19 Thread Steven D'Aprano
On Tue, 19 Jun 2007 18:54:41 +1000, Ben Finney wrote: > "Ethan Kennerly" <[EMAIL PROTECTED]> writes: > >> I really like properties for readonly attributes, > > Python doesn't have "readonly attributes", and to attempt to use > properties for that purpose will only lead to confusion. class Parr

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

2007-06-19 Thread Ben Finney
"Ethan Kennerly" <[EMAIL PROTECTED]> writes: > I really like properties for readonly attributes, Python doesn't have "readonly attributes", and to attempt to use properties for that purpose will only lead to confusion. > and their ability to make the interface more elegant, by hiding > uninteres

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

2007-06-18 Thread Jay Loden
Jay Loden wrote: > 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. Answering my own question,

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

2007-06-18 Thread Jay Loden
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 compatibi

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

2007-06-18 Thread Alex Martelli
Ethan Kennerly <[EMAIL PROTECTED]> wrote: ... > There are a lot of Python mailing lists. I hope this is an appropriate one > for a question on properties. yep, it's a fine one. > But a gotcha bit me in the behavior of properties that I didn't expect. > If another function accesses an underlyi

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

2007-06-18 Thread Ethan Kennerly
Hello, There are a lot of Python mailing lists. I hope this is an appropriate one for a question on properties. I am relatively inexperienced user of Python. I came to it to prototype concepts for videogames. Having programmed in C, scripted in Unix shells, and scripted in a number of proprie