Typing system vs. Java

xauau xauau at yahoo.com.au
Mon Aug 6 06:59:22 CEST 2001


"Alex Martelli" <aleaxit at yahoo.com> writes:

> the Pythonic idiom is to expose 'properties' (client-visible attributes) for
> client use with Python syntax (obj.theattr for reading, maybe also
> obj.theattr=newvalue if it's appropriate for the property to be writable),
> and, if accessor functions are needed, provide them behind the syntax
> screen (with __getattr__/__setattr__ in 2.1 and before, with dedicated
> per-attribute getters/setters in 2.2 and after). 

Yes, this is a seldom mentioned but very welcome addition to 2.2. It
wasn't hard to implement properties by hand, but having a standard way
will hopefully do away with getters and setters for good.

>  Object Pascal (at the heart of Delphi) has always worked like this
> (as, for read-access only, has Eiffel;

C# works the same way as Delphi in this respect.




More information about the Python-list mailing list