Python is wierd!

Tim Peters tim_one at email.msn.com
Tue Jul 25 03:17:22 EDT 2000


A few quickies:

[Jonathan]
> Hi, just finished going through the 'Learning Python' book, and the
> feeling that i get is that Python is really wierd(compared to other
> conventional languages like C++, Java, etc). For e.g.(correct me if i'm
> wrong)
> ...
> 3. No keywords to differentiate between passing arguments by reference
> or value! An integer is passed by value(reference to a new copy), while
> a mutable object is by reference. To pass a list by 'value', i know you
> just need to insert one more line(list = [:]), but it seems
> so 'inconsistent' compared to Java or even PHP.

I'm surprised you got that impression from the book.  It isn't a true one.
Everything in Python is passed by reference, always; Python never (ever!)
makes a copy of anything unless you explicitly ask for one.  What you
describe is actually much closer to the way Java works.

> (Not to mention the number of 'gotchas' listed in the book that are
> bound to trap beginners - *shudder*)

You'll find that (by far) most Python users believe the language has far
fewer gotchas than other languages they've used.  I'm certain the book did
*not* say the gotchas they list at the end of each chapter "are bound to
trap beginners".  Different people have different blind spots, and the
authors did a remarkable service by listing the *union* of "gotchas" they've
seen beginners get got by <wink>.  There are very few gotchas in Python that
*most* beginners suffer (stark contrast with C, C++ or Perl is dead easy).
See also Andrew Kuchling's "Python Warts" paper:

    http://starship.python.net/crew/amk/python/writing/warts.html

That lists deep areas of ongoing (and going, and going <wink>) debate.  The
"beginner gotchas" are much shallower, and the best predictor I know of for
which feature will trip which beginner is the programming language they used
most before coming to Python.  It's insane to believe that language X
"should" work exactly like language Y, and beginners who don't come in with
an insane attitude very quickly adjust.

As the years have gone by, I've gotten a sick, hypocritical thrill out of
cruising other language newsgroups, and finally seeing people complain that
language X, Y or Z doesn't work exactly like Python <0.9 wink>.

> The reason i'm picking up python is that i got sick of PERL:),

There are many here who came to Python for the same reason.  Don't expect
Python to act like Perl, and I predict you'll be happy.  If you left Perl
reluctantly, you may also want to give Ruby a try.  One suggestion:  stop
reading so much and write some damn code already <wink>.

> ...
> Pascal(for procedural) and Java(for OOP) is still the better choice to
> start off, IMHO.

Try to reserve judgment until you've actually used the language.  Are you
old enough to remember the then-famous 1977 paper "Ambiguities and
Insecurities in Pascal", by Welsh, Sneeringer and Hoare?  A frank discussion
of *any* language's lapses from perfection will scare the snot out of
anybody who only reads about the language.  The Python community is very
open about what they think is lacking in the language; curiously, though,
there's almost no consensus on what that is.

don't-reply-start-coding<wink>-ly y'rs  - tim






More information about the Python-list mailing list