python3: 'where' keyword
Andrey Tatarinov
elephantum at dezcom.mephi.ru
Fri Jan 7 12:56:41 EST 2005
Hi.
It would be great to be able to reverse usage/definition parts in
haskell-way with "where" keyword. Since Python 3 would miss lambda, that
would be extremly useful for creating readable sources.
Usage could be something like:
>>> res = [ f(i) for i in objects ] where:
>>> def f(x):
>>> #do something
or
>>> print words[3], words[5] where:
>>> words = input.split()
- defining variables in "where" block would restrict their visibility to
one expression
- it's more easy to read sources when you know which part you can skip,
compare to
>>> def f(x):
>>> #do something
>>> res = [ f(i) for i in objects ]
in this case you read definition of "f" before you know something about
it usage.
More information about the Python-list
mailing list