[Python-Dev] accumulator display syntax
Raymond Hettinger
python at rcn.com
Tue Oct 21 14:58:55 EDT 2003
More information about the Python-Dev mailing list
Tue Oct 21 14:58:55 EDT 2003
- Previous message: [Python-Dev] accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Skip Montanaro] > I understand all that. Still, the "best" syntax for these so-called > iterator comprehensions might have been the current list comprehension > syntax. Skip is right about returning to the basics. Before considering some of the wild syntaxes that have been submitted, I suggest re-examining the very first proposal with brackets and yield. At one time, I got a lot of feedback on this from comp.lang.python. Just about everyone found the brackets to be helpful and not misleading, the immediate presence of "yield" was more than enough to signal that an iterator was being returned instead of a list: g = [yield (len(line),line) for line in file if len(line)>5] This syntax is instantly learnable from existing knowledge about list comprehensions and generators. The advantage of a near zero learning curve should not be easily dismissed. Also, this syntax makes is trivially easy to convert an existing list comprehension into an iterator comprehension if needed to help the application scale-up or to improve performance. Raymond Hettinger ################################################################# ################################################################# ################################################################# ##### ##### ##### ################################################################# ################################################################# #################################################################
- Previous message: [Python-Dev] accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list