[Chicago] Can you write Perl in Python?

Martin Maney maney at two14.net
Thu Dec 29 00:26:53 CET 2005


On Wed, Dec 28, 2005 at 04:50:24PM -0600, Adrian Holovaty wrote:
> Ian Bicking wrote:
> > List comprehension... I knew I was forgetting some entire language
> > feature somewhere.

Generator comprehensions - I thought there might be some "new" language
features I hadn't considered.  (I've been using 2.4 for some months now
(ever since I migrated to Ubuntu), but it was such a gentle transition
I haven't yet sat down and reviewed the what's new document.  If I stop
resisting throwing yet more theoretically useful time at this puzzle,
maybe I can get that much good out of it, anyway.)

> 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.

*Lots* of whitespace can be omitted if you don't care to be able to
read the result - I'm sure my 138 byte hack would be at least 10%
larger if whitespace that got squeezed out were put back in.

I accidentally discovered that the string literal parser leaves
unrecognized escape sequences alone, so I didn't need to make one
literal a raw string.  One byte here, another byte there, rinse,
repeat...

-- 
ActiveX is popular with writers of viruses, trojans,
worms and malicious scripts of all kinds.



More information about the Chicago mailing list