List Comprehensions Enhancement

I have implemented some of the list comprehension syntax ideas that were discussed a while ago. Some examples: nums = [1, 2, 3, 4, 5] strs = ["Apple", "Banana", "Coconut"] print [3 * x for x in nums] print [x for x in nums if x > 2] print [(i, s) for i in nums for s in strs] print [(i, s) for i in nums for s in [f for f in strs if "n" in f]] For more details and a patch, see: http://www.cosc.canterbury.ac.nz/~greg/python/listcomp/index.html == Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand greg@cosc.canterbury.ac.nz <P><A HREF="http://www.cosc.canterbury.ac.nz/~greg/python/listcomp/index.html">List Comprehensions Patch</A> - Greg Ewing's implementation of enhanced list comprehensions syntax for Python (using "for" and "in" keywords). (11-Sep-99) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce@python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------
participants (1)
-
Greg Ewing