Newbie observations

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Dec 19 05:35:38 EST 2007


MartinRinehart at gmail.com a écrit :
> Warning! Complaints coming.
> 
> The good news is that 10-days of part-time Python coding has convinced
> me that I picked the right language. Now, observations.
> 
> First, it is absolutely horrible being a newbie. I'd forgot how bad it
> was. In addition to making a fool of yourself in public,

As my grand-dad used to say, better to make a fool of yourself once by 
asking a possibly dumb question than to remain one by not asking it !-)

> you have to
> look up everything. I wanted to find a substring in a string. OK,
> Python's a serious computer language, so you know it's got a function
> to do this. But where? 

Could it be in the string object itself ?-) Remember that Python is 
mostly an OO language, so the first thing to do is usually to inspect 
the type or read it's help in the Python shell.


> Look it up in the function reference. OK,
> where's the function reference? A line of code that you'd type in a
> second is a ten-minute search. Thank God for google.

FWIW, I'm certainly not a PHP newbie (wrote tens of thousands of PHP 
code those last years) and I *still* have to lookup the doc for most 
functions exact spelling and signature. This is a problem I usually 
don't have with Python, thanks to it's mostly consistent API and the 
Python shell.

> Second, would anyone mind if we tossed the semi-colon (which this
> newbie is forever forgetting)? I think the language is parsable
> without it.

It is, indeed. But keeping the semi-colon is a design decision, and a 
good one IMHO.

Given your argument, we should remove the instruction terminator (';') 
from C/C++/Java etc, because that's what newbies are forever forgetting 
- at least that's what I've been forgetting for a couple monthes when 
starting with C and Java !-)

More seriously, that's something you should get used too quite quickly, 
specially if your code editor does a good job at indenting Python code 
(because then it should not indent if you forget this semi-colon).

> Third, could our classes be a little more selfless? Or a lot more
> selfless? 

<this-dead-horse-has-been-beaten-to-hell-and-back/>

> The Stroustrup's idea of having the compiler, not the
> programmer, worry about the self pointer was an excellent decision.

It's IMVHO one of the worst design flaws of C++. FWIW, in languages that 
  support implicit self (or this or whatever it's named), I always use 
the explicit one - which I find way better than prefixing member 
variables with "m_".

But anyway, what you suggest is obviously something that'll never happen 
in Python. I won't explain *once again* why the explicit self in both 
the signature and the function's body is a GoodThing(tm), but you can 
google this ng for a couple previous explanations on that topic. Anyway, 
once you'll have a good enough knowledge of Python's object model, 
you'll understand by yourself - you may want to lookup the doc for what 
Python 'methods' really are and how the whole thing works.

> What was van Rossum thinking?

That readability counts, and that uniformity is a good thing.

Not to be harsh, but don't you think that 10-days experience is a bit 
short to discuss a language design ? There are lot of things in Python 
that newcomers usually dislike or find weird at first. Most of these 
points make sens when you finally gain enough experience with and 
knowledge of the language and suddenly all things fall in places, you 
see the big picture and these "weird things" make sens.

Not to say that Python is wart-free of course, but MVHO is that you need 
much more than ten days experience with a language to be able to make 
the difference between effective warts and sound -even if unusual- 
design decisions. Now of course, once you fully understand them, you're 
totally free to still dislike these design choices !-)

My 2 cents.



More information about the Python-list mailing list