[Python-ideas] The Descriptor Protocol...
Nick Coghlan
ncoghlan at gmail.com
Thu Mar 3 12:59:26 CET 2011
More information about the Python-ideas mailing list
Thu Mar 3 12:59:26 CET 2011
- Previous message: [Python-ideas] The Descriptor Protocol...
- Next message: [Python-ideas] The Descriptor Protocol...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Mar 3, 2011 at 9:53 PM, Andrew Svetlov <andrew.svetlov at gmail.com> wrote: > Something like: > Point -> var_name = namedtuple(var_name, 'xy') > ??? > > Take into acount, `->` operatior is not allowed into regular Python > code, only in function annotations as annotation for result value. > Maybe that close enough to our case? Not a bad idea at all, although I would use "as" for the purpose (it's already a keyword we use for funny not-quite-assignment operations). class Person: name as n = Str(n) address as a = Str(a) Point as p = namedtuple(p, 'x y') Might be too magic for most people's tastes, but it would definitely reduce the repetition problem. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-ideas] The Descriptor Protocol...
- Next message: [Python-ideas] The Descriptor Protocol...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list