Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gnat (29)

gnat
  (email not shown publicly)

Journal of gnat (29)

Friday June 29, 2001
05:41 PM

Python Friendship Project

[ #358 ]
I talked about the Python Friendship Project at YAPC. So I decided today to put my kilobytes where my mouth is.

I grabbed a copy of the Python PDF library from Report Labs and started to port it to Perl. I joined #python and asking tricky questions there.

I've already learned that it's really hard to do a direct translation of Python to Perl. There are some weird things that they have, which I haven't figured out what they're for, let alone how to do it in Perl.

I'm learning places where Python is easier. You can slice strings to get the effect of the substr() function (somestring[2:5] instead of substr($somestring,2,5)]. The import mechanism is cute (you can import symbols from a module, or you can import the module as a hash and access the symbols from that hash). The ability to declare variables on the C line: sub foo ($arg1, $arg2) { is really nifty too. I had the odd experience of having my code get BIGGER when I turned it into Perl. I'm pretty sure I can optimize it later, but it was still disconcerting.

I'm having a lot of fun imagining Damian Conway programming in Python. "What? No Klingon? How do I source filter? I can't?! What about blessing a regexp? What do you mean, a regexp is already blessed. This sucks!" :-)

I'm hating quoting. Triple quotes (C) is insane. And the degree of object orientation used in this is driving me bananas. And having slicing be an operation you can do on strings is cool, but it took me ages to decipher a particular piece of code and work out whether the thing being sliced was string or array.

So it's been a fun afternoon, and I feel a better person for it. I'm about 20% of the way along the road to Python mastery, I think, and I'm looking forward to learning more. That way when next I rant, I'll be able to rant authoritatively!

--Nat