[Chicago] Can you write Perl in Python?

Ian Bicking ianb at colorstudy.com
Thu Dec 29 02:17:11 CET 2005


Adrian Holovaty wrote:
> Ian Bicking wrote:
> 
>>List comprehension... I knew I was forgetting some entire language
>>feature somewhere.
> 
> 
> Maybe this helps somebody: I recently found out the space before the "for" in 
> a list comprehension is not necessary if it's preceded by a close 
> parenthesis. Only tested in Python 2.4.2.
> 
> For example, this is valid:
> [str(i)for i in range(3)]

I also noticed this works for saving another character:

   [str(i)for i in(0,1,2)]

And at least one lambda seems useful, because then you don't need a 
"return".  Now I'm just wondering why Martin has backslashes in his code...

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Chicago mailing list