[Chicago] Can you write Perl in Python?

Martin Maney maney at two14.net
Thu Dec 29 06:40:32 CET 2005


On Wed, Dec 28, 2005 at 10:31:15PM -0600, Edward S. Marshall wrote:
> I'm down to 198 bytes in a single line, without doing anything "clever"
> with my output template yet (ie. it's still one long string, instead of
> integers like everyone else seems to eventually move to). And if list
> comprehensions are your thing, it's still fairly readable (although the
> lack of whitespace and run-together nature is making me cross-eyed at
> this point). I'm convinced the only significant way I can make this
> smaller is to shrink my template representation.

That sounds about right.  I didn't save earlier versions, alas, but I
hit 206 bytes (with some substantial whitespace and inlining
improvements not yet performed) only after doing the first
transformation from having fairly simple templates (that is, each
digit's output representation was present as a disjoint bit of string
literal(s)) to the first compressed one.  That was still rebuilding the
nested lists of strings, but repeated parts were assigned once and then
included by name.  It's fairly straightforward to get the
representation down to one byte per digit, though there is of course a
partially offsetting increase in code bulk to render that!

> I can't believe I'm still banging away at this. My sense of style is
> greatly offended. ;-) I also disagree with the subject line; the farther
> I go with this, the more it starts to look like Lisp. It's a far cry
> from the visual abuse you can deliver with Perl.

I see what you mean, though it's not as confusing to the eye - my eye,
at least - as Lisp gets because they're not all parentheses.  Or not
all "round" parentheses, if you want to look at it that way.  I do
understand the comparison with Perl, though.  I, at least, do not
normally write Python with such a high proportion of punctuation as
this has become.  :-)

-- 
We've all heard that a million monkeys banging on
a million typewriters will eventually reproduce
the entire works of Shakespeare.  Now, thanks to the
Internet, we know this is not true.  -- Robert Wilensky



More information about the Chicago mailing list