This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients docs@python, eric.araujo, ezio.melotti, mark.dickinson, mattlong, terry.reedy
Date 2011-12-08.17:10:19
SpamBayes Score 3.1397107e-13
Marked as misclassified No
Message-id <1323364220.0.0.407171061774.issue13549@psf.upfronthosting.co.za>
In-reply-to
Content
> - I’d recommend a few whitespace beautifications,
> like in ``for x in [1,2,3]`` and ``range(1,6)``.
Leaving the space out in [1,2,3] makes the expression a bit more readable IMHO*.


>  I think there is an example that makes that line more
> understandable, but it’s in the section about tuples, not here in the 
> listcomp section; you may or may not want to improve that too.
What needs to be parenthesized are tuple literals, and I think people at this point of the tutorial still think that () are required to make a tuple, so they would probably put them anyway.  IOW the example that uses them, the note, and the example that fails are probably enough already.

> - Maybe a link to the itertools module is appropriate (either after 
> the combinations example, or after the link to the built-in zip 
> function).
I was going to add it, but then realized that itertools' functions don't return lists, so they are a bit unrelated (and maybe it's too early to introduce itertools at this point of the tutorial).


* the idea is to separate better different elements, even if the single elements are a bit less readable:
2 * 3          is ok (you are multiplying two numbers)
2*3 + 4*5      is ok (you are adding two products)
2 * 3 + 4 * 5  is less readable (you have to parse the operations)
2 * 3+4 * 5    is misleading (it looks like the product of 3 numbers)
Similarly:
[(1,2,3), (3,4,5), (5,6,7)]  is ok (you have a list with 3 tuples)
[(1, 2, 3), (3, 4, 5), (5, 6, 7)]  is less readable (the space are used to separate both the tuples and the elements in there, and you have to parse the () to see where the tuples start and end).
YMMV though.
History
Date User Action Args
2011-12-08 17:10:20ezio.melottisetrecipients: + ezio.melotti, terry.reedy, mark.dickinson, eric.araujo, docs@python, mattlong
2011-12-08 17:10:20ezio.melottisetmessageid: <1323364220.0.0.407171061774.issue13549@psf.upfronthosting.co.za>
2011-12-08 17:10:19ezio.melottilinkissue13549 messages
2011-12-08 17:10:19ezio.melotticreate