[Python-ideas] The Descriptor Protocol...
ncoghlan at gmail.com
Thu Mar 3 12:59:26 CET 2011
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).
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.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas