Python is readable

Chris Angelico rosuav at gmail.com
Thu Mar 15 06:50:59 EDT 2012


On Thu, Mar 15, 2012 at 9:44 PM, Kiuhnm
<kiuhnm03.4t.yahoo.it at mail.python.org> wrote:
> Let's try that.
> Show me an example of "list comprehensions" and "with" (whatever they are).

I'll do a list comp, because they lend themselves well to one-liners.
what_am_i = '\n'.join(["%X\t%c"%(i,i) for i in range(128)])

Okay, that one also uses printf formatting, which may be a smidge
obscure. Here's a simpler example:

what_am_i = [x*x for x in range(11)]

ChrisA



More information about the Python-list mailing list