Any syntactic cleanup likely for Py3? And what about doc standards?

Ferenczi Viktor python at
Thu Sep 6 01:28:03 CEST 2007


> > from property_support import hasProperties, Property
> >
> > @hasProperties
> > class Sphere(object):
> >     def setRadius(self, value):
> >         ... some setter implementation ...
> >     radius=Property(default=1.0, set=setRadius, type=(int, float))
> >     color=Property(default='black', allowNone=True)
> >
> > This is a cleaner syntax if you need automatic default setter/getter
> > implementations with type checking, default values, etc

> I really distaste this "etc." in your description. In the end you
> promote endless lists of command line parameters to configure every
> possible function. I also doubt that the solution is more clean but
> arbitray instead.

Py3K does not enforce any particular use of the class decorator function. This 
was only an example.

> My own guess why properties are not promoted with more emphasis is
> that they lead to cargo cult programming i.e. everyone starts to use
> property syntax even when usual attributes are sufficient. So the
> syntax might even be intentionally ugly.

AFAIK there is no such a thing as "intentionally ugly" in the Python language. 
I've never read this sentence before in manuals, tutorials, etc.

Certainly, an attribute should be replaced by a property if and only if 
additional functionality is required, such as type or value checking, 
calculated value, ability to register observers for various events fired by 
the property and so on.

This is advanced Python programming, not "cargo cult".

Regards, Viktor

PS.: Use Python 1.5.2 if you do not need advanced features. ;-)

More information about the Python-list mailing list