4 ms·
Generator Expressions in Python: An Introduction
- oldandtired 9y agoI 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 9y agoI 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.
- lispm 9y ago"für x in z" should be perfectly comprehensible für Programmierer in Deutschland.
- timonoko 9y agoOk. I have only Approbatur in Deutsch.
- kazinator 9y agoThe 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 9y agoAchso. 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?