Paddy O'Loughlin a écrit :
2009/2/20 Bruno Desthuilliers <bruno.42.desthuilli...@websiteburo.invalid>:
Note that while you *can* do direct access to the implementation attribute
(here, '_A' for property 'A'), you don't *need* to so (and usually shouldn't
- unless you have a very compelling reason).
Interesting. Why shouldn't you?
I haven't used the property() function
s/function/object/
before and probably have no
call to, but when you say "usually shouldn't", what is there against
it?
The case is that the whole point of using a computed attribute is to
perform some computation on the value. IOW, except for a couple corner
cases, only the accessors should directly access the implementation(s)
attributes(s).
And of course, like for any other GoldenRule(tm), it's not meant to be
blindly followed. It's just that most of the times, going thru the
accessors is really what you want - even from within the class code.
--
http://mail.python.org/mailman/listinfo/python-list