[Python-ideas] C# style properties
greg.ewing at canterbury.ac.nz
Sat Jul 14 04:58:46 CEST 2007
Neil Toronto wrote:
> Inner-class-as-a-class-variable is the
> mental leap you have to make, plus you have to be comfortable with
Actually, I think there's a further mental leap you have
to make -- the notion that a 'class' statement can create
something that is *not* a class. Just knowing that there
is a metaclass involved is not enough to alert you to
IMO this is something that should definitely not be
encouraged, as it directly obfuscates the code --
you're saying 'class' when you don't really mean it.
> It might be nice to be able
> to declare a one-off namespace:
Yes, things like this have been suggested before.
There was a thread not long ago about a 'make'
statement, for example, and there have been numerous
suggestions for a 'namespace' statement.
My favourite version would be something like
def __set__(self, x):
which would be roughly equivalent to
foo = _foo()
but without the intermediate class name.
More information about the Python-ideas