sturlamolden a écrit :
Personally I find properties atrocious and unsafe.
What a strange observation from someone wanting to introduce defmacros
and customizable syntax in Python....
One cannot
distinguish between a function call and binding an attribute in a
statement like:
FWIW, "binding an attribute" will *alway* require some function call...
Properties - or any other computed attributes - are just hooks into the
default __setattr__ implementation so you can customize it.
foo.bar = 2 # Does this call a function or bind an attribute?
From the client code POV, it binds an attribute - whatever the
implementation is.
From the implementation POV, it will always call a couple functions.
What's you point, exactly ?
# Is this foo.setBar(2) or setattr(foo,'bar',2)?
Why do you care ? Ever heard about the concept of "encapsulation" ?
Even worse: if we make a typo, the error will not be detected as the
syntax is still valid.
So what ? This has nothing to do with properties.
Properties and dynamic binding do not mix.
Sorry, but IMVHO, this is total bullshit.