| |
| | Python: List Comprehensions (Site not responding. Last check: 2007-10-23) |
 | | The interesting thing is that we first build a list of non-prime numbers, using a single list comprehension, then use another list comprehension to get the "inverse" of the list, which are prime numbers. |
 | | When you can use both, then it is often preferable to use a list comprehension, because this is more efficient and easier to read, most of the time. |
 | | You cannot use list comprehensions when the construction rule is too complicated to be expressed with "for" and "if" statements, or if the construction rule can change dynamically at runtime. |
| www.secnetix.de /~olli/Python/list_comprehensions.hawk (462 words) |
|