perl to python

Kirk Job-Sluder kirk at eyegor.jobsluder.net
Wed May 12 12:43:29 EDT 2004


On 2004-05-12, Ville Vainio <ville at spammers.com> wrote:
>>>>>> "Kirk" == Kirk Job-Sluder <kirk at eyegor.jobsluder.net> writes:
>
>    Kirk> And here is the fundamental question.  Why should I spend my
>    Kirk> time writing a module in python to emulate another tool,
>    Kirk> when I can simply use that other tool?  Why should I, as a
>
> Perhaps you won't; but someone who isn't already proficient with the
> tool may rest assured that learning the tool really isn't worth his
> time. awk and sed fall into this category.

Actually, I'm not convinced of the learning time argument.  It takes
about 30 minutes training time to learn enough awk or sed to handle 
90% of the cases where it is the better tool for the job.  A good
understanding of regular expressions will do most of your work for you no
matter which langugage you use.  

>    Kirk> resarcher who must process large quantities of data, spend
>    Kirk> my time and my employer's money reinventing the wheel?
>
> You are not reinventing the wheel, you are refactoring it :). I don't
> think your employer minds you spending 15 extra minutes creating some
> tool infrastructure, if it allows you to drop awk/sed dependency that
> your co-workers then won't need to learn.

In which my case, the perl version is more likely to win out on the
basis of standardization.  IME, the time involved to create good
infrastructure that does not come back to bite you in the ass is
considerably more than 15 minutes.  Think also that for every minute you
spend designing something to share, you need to spend between 5-20
documenting and training in the organization (and this is not including
maintenance and distribution.)

The great thing is that the tool infrastructure already exists.  Not
only does the tool infrastructure exist, but the training materials
already exist.  Really, how hard is "perl -pi -e 's/foo/bar/'" to
understand?  How hard is "sed -e 's/foo/bar/' < infile > outfile" to
understand?  How hard is a shell script to understand?

> I find writing pythonic tools a relaxing deversion from my everyday
> work (cranking out C++), so I don't really mind. As long as the time
> spent is within 5 minutes - 1 hour range.

Well, there is another big difference. I'm a big fan of instant
gratification so the off-the-shelf tool that does the job in 10 seconds
is better than 5 minutes to 1 hour writing a pythonic tool.  I have
re-written shell scripts in python just for kicks, but I don't have any
illusions that refactoring everything into python should be a
perogative.




More information about the Python-list mailing list