Python is wierd!

Jonathan theebh at yahoo.com
Tue Jul 25 08:32:05 EDT 2000


In article <LNBBLJKPBEHFEDALKOLCOEMPGLAA.tim_one at email.msn.com>,
  "Tim Peters" <tim_one at email.msn.com> wrote:
> 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.

Oops...maybe i typed too fast! What i meant to say was: passing an
immutable object by reference simulates the "pass-by-value" feature of
other programming languages. And the book did make it clearly:)
>
> > (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.
>
Yep, point taken. I think the book did a good job by listing out all
the potential gotchas that might trap a newbie. What i was thinking is
the nature of the 'gotchas' that arise in python. My knowledge in
programming is quite shallow(i must admit), and my progress was
from 'pascal'->'c'->'c++/java'->'perl'->'php'. Along the way, of course
there are a few 'gotchas' in each language, but most of them did not
throw much surprises(except perl - the 'blessing' part for e.g.)

> 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>.
>
ok, ok i'm trying to write some codes soon:) I don't expect Python to
be the same as PERL, else i wouldn't have bothered picking it up:)

> > ...
> > 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
>
I'm making this judgment from a perspective of a newbie to python,
comparing to my experience with these 2 languages(back when i first
started learning them). I'm thinking back which one has been easy to
pick up so far, and which one helps me to understand programming
principles. Things like strict typing, declaration of
functions/variables, difference btwn pass-by-value or pass-by-
reference, static or instance variables, (etc) seems easier to explain
to a newbie in Pascal or Java (of course i dun mean to use pascal for
serious programming purposes).

regards,
jonathan


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list