[Python-Dev] PEP 318: Set attribs with .name = value
Ka-Ping Yee
python-dev at zesty.ca
Tue Mar 30 06:17:31 EST 2004
Someone suggested the following syntax for setting function attributes:
def func(arg, arg):
.author = 'Guido van Rossum'
.version = 42
Guido replied that he wanted to reserve ".name = value" for use in
"with" blocks.
These two uses are not in conflict at all -- in fact, they are
perfectly compatible and i find the syntactic consistency elegant.
I think the above syntax for function metadata is by far the cleanest
and simplest method i have seen, and its meaning is the most obvious
of all the proposed syntaxes. After "def func...: .version = 42" it
makes sense that func.version should equal 42.
I am also happy with the idea of "with":
with some[long].expression:
.attrib = .something + something
It all fits together beautifully.
def func(arg, arg) [optimized, classmethod]:
.author = 'Sir Galahad'
.version = 42
"""Description."""
code
more code
-- ?!ng
More information about the Python-Dev
mailing list