
Generator Expressions in Python: An Introduction - dbader
https://dbader.org/blog/python-generator-expressions#.
======
oldandtired
I find it interesting that languages, which copied the generator concept from
icon, have not gone the full process and copied the success/fail concepts as
well.

The two concepts (as well as co-expressions) go so well together and make many
of the aspects of code writing simpler and easier to both read and write.

I use unicon as my go to language today. Even though it misses some language
features that I would like to see incorporated, it handles my day to day
programming needs. Since unicon is built upon icon, I can say that I have been
using icon since 1986.

In the case of Python,I find the incorporation of generators a klunky addition
to the language. It's nice to have but they didn't go far enough. But then
again, I do suppose it would have changed the entire nature of Python to have
incorporated success/failure into the language in the manner of icon/unicon.

------
timonoko
I think I finally know what is wrong with this crap and Common Lisp loop-
macro: The "X for Y in Z" is comprehensible only to native English speaker.
Try "X für Y im Z" or "X för Y i Z".

In other worlds, most other languages not have "I am red for (sitting in) the
sun"-type construct. One has to read it 3 times, because it is not "because",
but some kind of post-fix adjective notation.

~~~
kazinator
The CL _loop_ macro doesn't have an _X for Y in Z_ clause; just _for X in Y_.
This is not directly English, but an abbreviation of the pattern "for
{each|every} X in Y ...". It is the associative _for_ : the action is
dedicated separately to each item; it is _for_ each item.

Non-native English speakers working internationally better understand it
because it's a common idiom in business, due to the frequent need to deal with
the processing of multiple items. "Please forward me your TPS report for each
month of 2016". :)

~~~
timonoko
Achso. Now I understand the issue here: "For" should be "For Each".

The weird ('Hello' for i in range(3)) becomes totally comprehensible in the
form of ('Hello' foreach i in range(3)).

Making M4-macro for "foreach". Or is there some pythonic way to do this?

