Is a "real" C-Python possible?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Thu Dec 13 19:30:27 EST 2007
On Thu, 13 Dec 2007 13:35:24 -0800, sturlamolden wrote:
> On 13 Des, 19:16, "Chris Mellon" <arka... at gmail.com> wrote:
>
>> I don't feel that it's especially inconsistent, and I like decorators.
>> Having to write foo everywhere isn't that nice, but it's only mildly
>> worse than C# to me - I find the extra block levels really atrocious.
>
> Personally I find properties atrocious and unsafe. One cannot
> distinguish between a function call and binding an attribute in a
> statement like:
>
> foo.bar = 2 # Does this call a function or bind an attribute?
> # Is this foo.setBar(2) or setattr(foo,'bar',2)?
Why do you care?
As the class *creator*, you care, but as the class *user*, you shouldn't
need to -- at least assuming it is a well-written class. (You might care
if the class' setter has harmful side-effects, but that's no difference
from a class with a __setattr__ method with harmful side-effects.)
> Even worse: if we make a typo, the error will not be detected as the
> syntax is still valid. Properties and dynamic binding do not mix.
I'm not quite sure I understand that criticism. How is that different
from things which are not properties?
foo.baz = 2 # oops, I meant bar
will succeed regardless of whether foo.bar is an attribute or a property.
--
Steven
More information about the Python-list
mailing list