Typing system vs. Java

Alex Martelli aleaxit at yahoo.com
Mon Aug 6 01:28:12 EDT 2001


"xauau" <xauau at yahoo.com.au> wrote in message
news:877kwhiy1h.fsf at xeno.localhost...
> "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,

Full agreement (I should also mention that using Boost Python, BPL, has
long given the same ability -- BPL uses the metaclass hook to make full
Python classes from C++ classes, and as a side benefit it lets one write
specific getters/setters for any Python class extending a BPL one).

> but having a standard way
> will hopefully do away with getters and setters for good.

Wanna bet?-)  People are sometimes high-inertia systems:-).  Having
learned one good workable way to do something, they may not switch
to another better way when the latter becomes available.  People are
also (in many cases) excellent at rationalization -- finding reasons that
sound good for what they want to do anyway -- so we can confidently
look forwards to many flam^H^H^H^H constructive discussion
threads on this subject...!


> >  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.

Good point, I keep forgetting to mention the similarities of C# to Object
Pascal (no doubt many of them related to having the same architect:-).


Alex






More information about the Python-list mailing list