On 5/6/2009 6:48 AM J Kenneth King said...
Emile van Sebille <em...@fenx.com> writes:
On 5/5/2009 9:15 AM J Kenneth King said...
The Python documentation discourages their use and I believe
for good reason.
Can you provide a link for this? I'd like to see specifically what's
being discouraged, as I'd be surprised to find routine usage frowned
upon.
http://docs.python.org/tutorial/datastructures.html#nested-list-comprehensions
Thanks.
"If you’ve got the stomach for it, list comprehensions can be
nested. They are a powerful tool but – like all powerful tools – they
need to be used carefully, if at all."
Yes, although this is in reference to nested list comprehensions. Eg,
[xx for xx in [yy for yy in [zz for zz in iterable if z] if y] if x]
The section above on list comprehensions advocates their use saying:
"List comprehensions provide a concise way to create lists without
resorting to use of map(), filter() and/or lambda. The resulting list
definition tends often to be clearer than lists built using those
constructs."
Emile
--
http://mail.python.org/mailman/listinfo/python-list