Does Python really follow its philosophy of "Readability counts"?

Luis Zarrabeitia kyrie at uh.cu
Mon Jan 19 23:13:18 EST 2009


Quoting "Russ P." <Russ.Paielli at gmail.com>:

> One of the main benefits of properties is that they allow you to more
> safely put attributes in the public interface. If you later decide
> that the attribute shouldn't have been in the public interface, you
> can convert it to a property and make it do whatever you want it to
> do. That won't always save you, but sometimes it can.

That's true in Java, and python pre-'descriptor protocol'. 

It boggles me when I see python code with properties that only set and get the
attribute, or even worse, getters and setters for that purpose. In my university
they teach the students to write properties for the attributes in C# ("never
make a public attribute, always write a public property that just gets and sets
it"). I never understood that practice either, given that the syntax for
attribute access and property access in C# is exactly the same. (Could it be
that even if the syntax is the same, the compiled code differs? Don't know
enough about .NET to answer that).

I think I'm getting offtopic now. I better leave :D

[snip the rest of the email, as I agree with it]

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie



More information about the Python-list mailing list