[Python-ideas] Dart-like method cascading operator in Python
Steven D'Aprano
steve at pearwood.info
Fri Nov 22 12:33:09 CET 2013
On Fri, Nov 22, 2013 at 10:32:13AM +0100, Perešíni Peter wrote:
> Actually, thinking about my own ideas -- the bigger problem than yield is
> the return. I am not sure if things like
>
> return list(range(10))
> ..reverse()
> ..pop(0)
>
> should be allowed or not - having something being executed after the return
> statement line might be a bit confusing
If Python gains this syntax, I don't see why that shouldn't be allowed.
That some of the lines of code occur physically after the return keyword
is no more a problem than here:
return (spam()
+ eggs() + toast()
+ milk() + cookies()
)
In your case, the suite
list(range(10))
..reverse()
..pop(0)
is evaluated first, and then returned.
--
Steven
More information about the Python-ideas
mailing list