Migrating to perl?

Tim Peters tim.one at home.com
Thu Jan 4 22:28:34 EST 2001


[Joel Ricker]
> I'm thinking of moving from perl to python and I was looking for
> opinions on the difference.

Don't bother <wink>.  Seriously, download Python, install it, and work your
way through the tutorial that comes with it.  In no more than a few hours
you'll know for certain whether Python is for you!  Much more efficient than
guessing whether the replies you get here are lying <wink>.

> ...
> So basically what I'd like to know is, how do the two compare?

Python's motto is "there's only one way to do it" -- they're polar extremes
in some ways.  Python is very uniform in its syntax and semantics (compared
to Perl, not compared to e.g. Scheme).  That can make it wordier than Perl,
and, in some cases, slower (for example, regular expressions are just
another module in Python -- the language proper knows nothing at all about
them, so can't special-case the snot out of them).  On the other hand, the
uniformity and makes it much easier to read other peoples' code, and that
includes your own.

> Is there an easier learning curve with Python?

Absolutely -- try the tutorial and judge for yourself.

> Are the modules and add-ons as good as perl (ie, Database --
> I'm primarily interested in MySQL, CGI, Graphics).

I haven't done any of that stuff in Python; must leave for someone else.

> What about OOP?  Is it it a full OO language?  Is it easier than
> to use than perl?  Perl OO just feels like it has been cludged
> together.

A simple example should make this clear immediately (cut from an interactive
Python shell session):

>>> # Make a class with a method
>>> class C:
        def amethod(self, anargument):
            return anargument + 1

>>> # Subclass it
>>> class D(C):
        def anewmethod(self, anargument):
            return anargument + 2

>>> # Instantiate an instance
>>> d = D()
>>> # Invoke methods
>>> d.amethod(42)
43
>>> d.anewmethod(42)
44
>>>

You even get to name your arguments in Python, just like in a real language
<wink>.

> And lastly, what about the Python community?  Is it friendlier
> than the perl community?  Too many times I've asked questions and
> all I'll get is pointers to documentation, which I've already
> read and so thats why I'm asking for information in the first
> place.  I understand simple questions for basic or novice
> information will warrant answers like that but not the things I've
> asked.

The day I was proudest of comp.lang.python was a day last year when, at a
very busy time, someone posted the question "what's a text editor?".
Amazingly, they got several gentle introductions to the topic.

That doesn't mean we're not vicious, though:  just try suggesting that
Python should add curly braces <0.9 wink>.

you-also-have-to-put-with-<wink>s-and-stupid-signoff-
    lines-here-ly y'rs  - tim





More information about the Python-list mailing list