Python questions from C/Perl/Java programmer

Jonadab the Unsightly One jonadab at bright.net
Fri Sep 8 04:46:36 EDT 2000


Tom Biggs <biggs at erols.com> wrote:

> Oh, hello, I'm a complete Python newbie; I just dropped in to pick up tips.
> I learned Perl through monitoring that newsgroup.  I'm a fanatic Perl
> programmer but not to the exclusion of all else.  I've done C for umpteen
> years now, but I'm not attached to the curlies.

Braces are okay.  I don't mind braces.  Having to declare each
and every variable is what bugs me, one of the reasons I 
*still* don't use C after years programming in other languages.
(I *will* get to C, though, if only because it is ubiquitous.)

> The only reason I was even a bit leery of fixed indents was
> that my first language was Frotran, 

Oh, *columns*.  That goes *WAY* beyond this kind of indenting.
"Yes, if you put an * or a % in column 17, UNLESS there is also
a C in column 0 or 1, ..."  Okay, by '77 Fortran wasn't quite 
THAT bad.  Actually, modern Fortran is a pretty good language
if one of the main things you want to do is calculate really 
huge numbers (numbers, in some cases, that would span onto 
multiple pages if you tried to print them out -- say, if you're 
researching weather prediction algorithms or something).  (It
still isn't good for text-munging and such, though.)

> long before it got proper
> control structures.  But I'm compulsive about proper indenting
> in C and Perl, so Python's use of indenting to eliminate the
> curlies doesn't bother me in the least.  I've seen some frightening
> C and Java code where the 'indenting' served only to confuse;
> it was indecipherable until run through the indent utility.

This is where Emacs comes in handy.  Select the whole buffer,
indent-region once, and presto.  Actually, that's not quite
true.  If they try really *hard* to make it obfuscated, 
they'll do "creative"[1] things with the line breaks that 
will confuse indent-region, so then you have to write a custom 
script to put in newlines after every semicolon...

> Several Perl/C/Java programmers I know raved so about Python
> that I just had to investigate.  I like what I've seen so far _very much_.

I mostly heard about Python from Perl people, who say things
like "C# is evil" and "Perl's competition should be Python".

> I doubt I'll abandon Perl altogether 

I won't.  Then again, I haven't abandoned BASIC altogether either,
I just abandoned using it for certain things that other languages
do better.  For example, since I learned elisp and Perl I no longer
use QBasic for text-munging scripts, because it isn't the best tool
I have for the job.  But there are other things I still use it for.
The only languages I abandon are the ones I can't stand (such 
as Lingo and CoBOL), the ones I don't have a compiler or interpreter
for (like Fortran and VB), and the ones that I just still don't know
well enough to use effectively (like C and C++).  I might also 
leave off using a language if another language simply makes every
single thing easier, but that would be unusual.  (Perhaps if I
knew Awk (which I don't), I might feel that Perl obviates it.
Oh, and I almost never use GW-BASIC because QBasic can do pretty
much everything I did with it[2].)

> - I try to pick the right tool for the
> right job - but Python looks very clean.  

So far.  I'm very new at it, though.

> And Perl's OO stuff is just
> ridiculous, a hasty slap-on-the-side kludge.

I concur.  I *like* Perl, but I don't like its OO model.
I will use it mainly for non-OO implementations.

Of course, I don't demand that every language be OO.  Some
problems don't lend themselves particularly well to an
object-oriented solution.  (Others do.)  So far the only
really OO language that I know well and like is Inform,
and it's great, but it's not a general purpose language
really, and there are a lot of things it's not good for.
So I decided to pick up another OO language.  I decided
against C++ mainly because the two times in the past that
I've tried to learn it I ran into a brick wall labelled
"really lousy documentation".  So I've determined to
skip it for now and come back after I learn C (which
will not be until after I learn Python, because I know
rather more non-OO languages than OO ones and want to
add an OO language first).  But I digress.

> So you'll probably be hearing some newbie questions from me.
> *After* I read the FAQ of course...

I am finding the FAQ a lot less helpful than the tutorial 
and library reference, FWIW.

[1]  By which I mean counterintuitive in the extreme, of course.

[2]  Not everything it can do; just everything *I* did with it.

- jonadab



More information about the Python-list mailing list