Adding static typing to Python

Don O'Donnell donod at home.com
Thu Feb 21 00:47:38 EST 2002


Fernando Pérez wrote:
> 
> Courageous wrote:
> 
> >
> > One of the things I like about C sharp is their use of attributes,
> > where you can define getters and setters on an attribute, but
> > otherwise the attribute is simply used as if it were a public one.
> > An objects attributes can thereby be used as a published aspect of
> > its interface safely, but no one will be the wiser if you manipulate
> > the getter and setter code.
> 
> Just curious, isn't there something quite similar to what you describe in
> py2.2? I've only glanced at it so I could be wrong...
> 


Yes, there is, and it's not new with C#.  I think something like
attributes with transparent getter and setter methods have been in VB at
least since version 6.

I am just starting to look at the Python implementation.  It is based on
a new built-in type called property.  In 2.2, at the interactive prompt,
type:

>>> print property.__doc__

And read Andrew Kuchling excellent "What's New in Python 2.2", Section
2.4 Attribute Access:

http://www.amk.ca/python/2.2/index.html#SECTION000340000000000000000

Have fun.

Don



More information about the Python-list mailing list