Andrey Tatarinov wrote:
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:
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
def f(x):
#do something
association). And it's not that unpythonic - it resembles
res = [x for x in sequence if x.isOk()]
print words[3], words[5] where:
words = input.split()
words = input.split()
print input.split()[3:5:2]
- 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,
Yes, I like the readability of it, too.
compare to
in this case you read definition of "f" before you know something about
it usage.
When I first read your post, I thought "Well, just one more of thoseone expression
- it's more easy to read sources when you know which part you can skip,
Yes, I like the readability of it, too.
compare to
def f(x):
#do something
res = [ f(i) for i in objects ]
#do something
res = [ f(i) for i in objects ]
it usage.
Py3k ideas that appear on c.l.py every day." But as I look at the latter
example, I think you have just scratched my itch. The same thing has
bugged me more than once in my code.
I think this idea is of the same kind as the @decorator syntax. Guido
moved an operation to a point in the code where it was more visible. You
moved an operation to a more local context where (pun not intended) it
really belongs.
I'm usually rather conservative about Python syntax (@decorators,
absolute/relative imports, if-else operator), but this one could appear
in Python tomorrow and that would be too far in the future for me ;)
Cheers,
AdSR