[Python-ideas] Assignment decorators (Re: The Descriptor Protocol...)

Ethan Furman ethan at stoneleaf.us
Fri Mar 4 00:25:14 CET 2011


Greg Ewing wrote:
> I've also had another idea on how to approach the problem
> without involving the decorator concept:
>> def name as something(arg, ...)
>> would be equivalent to
>> name = something('name', arg, ...)
>[snip]
>> or
>> def Fred as namedtuple('x y z')

This I like. Do we even need the def?
class Person(object):
 name as Str()
 address as Str()
I don't think I've seen it mentioned yet (my apologies if I missed it), 
but we could also add more magic and make the assigned name an available 
attribute to the function when it's called.
~Ethan~


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /