Crazy what-if idea for function/method calling syntax
Ian Kelly
ian.g.kelly at gmail.com
Sun Jul 17 23:29:45 EDT 2011
2011/7/17 ΤΖΩΤΖΙΟΥ <tzotzioy at gmail.com>:
> Jumping in:
>
> What if a construct
>
> xx(*args1, **kwargs1)yy(*args2, **kwargs2)
>
> was interpreted as
>
> xxyy(*(args1+args2), **(kwargs1+kwargs2))
>
> (Note: with **(kwargs1+kwargs2) I mean "put keyword arguments in the
> order given", since dicts can't be added)
>
> This construct is currently a syntax error. The intent of this idea is
> to help improve legibility.
>
> Example:
> def place_at(item, x, y): blah blah
> could be called as
> place(item)_at(x, y)
class place(object):
def __init__(self, item):
self.__item = item
def at(self, x, y):
# place self.__item at (x, y)
pass
Then you can do:
place(item).at(x, y)
No syntax changes required. :-)
More information about the Python-list
mailing list