Newbie observations

M

MartinRinehart

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, 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? 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.

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

Third, could our classes be a little more selfless? Or a lot more
selfless? The Stroustrup's idea of having the compiler, not the
programmer, worry about the self pointer was an excellent decision.
What was van Rossum thinking?
 
J

John Machin

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,
[snip]


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

Do you mean colon?
 
S

Steven Bethard

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, 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? 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.

If you're having trouble with some of Python's basic syntax (like
slicing), you should go through the tutorial first:

http://docs.python.org/tut/tut.html

It doesn't take too long, and you'll hit slicing by section 3.1.2.
Second, would anyone mind if we tossed the semi-colon (which this
newbie is forever forgetting)? I think the language is parsable
without it.

What are you using them for? They're only intended to separate two
simple statements on the same line. I always use one statement per
line, so I never see semi-colons. I highly recommend that you never use
semi-colons either.
Third, could our classes be a little more selfless? Or a lot more
selfless? The Stroustrup's idea of having the compiler, not the
programmer, worry about the self pointer was an excellent decision.
What was van Rossum thinking?

http://www.python.org/doc/faq/gener...ed-explicitly-in-method-definitions-and-calls
 
R

Rick Dooling

But where? 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.

Maybe this will help:

http://rgruet.free.fr/PQR25/PQR2.5.html

But since you're already a programmer, you really should take an hour
and read the tutorial. It was written for people like you.

rd
 
B

Bruno Desthuilliers

(e-mail address removed) 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?

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.
 
M

MartinRinehart

My 2 cents.

Eurozone? That would be 3 cents US.

I meant colon, not semi-colon. I did the tutorial. I did objects 3
times.

In Java, the agreed convention is to use lowerAndUpper naming for
member variables. (See http://www.MartinRinehart.com/articles/code-conventions.html#5_1
..)

10 days is not enough. But I don't have any more clarity in my Python
classes than I did in Java. Just more "self"s.
 
M

Marco Mariani

10 days is not enough. But I don't have any more clarity in my Python
classes than I did in Java.

You do when you start using classes the python way, and do things that
are not even thinkable in java or any static language.
 
D

Diez B. Roggisch

Eurozone? That would be 3 cents US.

I meant colon, not semi-colon. I did the tutorial. I did objects 3
times.

In Java, the agreed convention is to use lowerAndUpper naming for
member variables. (See
http://www.MartinRinehart.com/articles/code-conventions.html#5_1 .)

10 days is not enough. But I don't have any more clarity in my Python
classes than I did in Java. Just more "self"s.

Believe me: I do java for a living, but I'm hoping to change that ASAP to go
with python (and the occasional C) - because my expressiveness in Python is
so much larger than with Java. Mixins, higher-order functions, Metaclasses,
decorators, properties, multiline strings, local functions in Java? No,
sir!

The thing is: self won't go away. Others have tried it - and didn't succeed.
Try and adapt. If you can't, you won't get happy with python - because its
not going to change.

Diez
 
P

Peter Otten

MartinRinehart said:
10 days is not enough. But I don't have any more clarity in my Python
classes than I did in Java. Just more "self"s.

Watch your classes evolve over the next weeks. They will get smaller,
with less state and fewer methods with less code. Occasionally you will use
a function or generator instead of a class, an inlined expression where
you used to write a custom function. You'll ditch code as you
discover that the standard library already provides a more general
way to achieve what you wanted.

If you don't share the experience sketched above you are likely moving in
the wrong direction.

Peter
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
Eurozone? That would be 3 cents US.

I meant colon, not semi-colon. I did the tutorial. I did objects 3
times.

That's not where you'll learn the inners of Python's object model. You
may want to browse this thread for some hints:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/7943ab9f93854eb6
In Java, the agreed convention is to use lowerAndUpper naming for
member variables. (See http://www.MartinRinehart.com/articles/code-conventions.html#5_1
.)

It's also the convention used for local variables, so unless you do
explicitely use the 'this' reference, it's not clear whether a name is a
local variable or a member variable - you have to check the function's
code for local variables declarations, then eventually the class
definition, then the parent's class etc.
10 days is not enough. But I don't have any more clarity in my Python
classes than I did in Java. Just more "self"s.

The "more self's" already gives you more clarity, even if you don't
realize it yet. Now 10 days is not also not enough to switch from Java
thinking to idiomatic Python. C/C++/Java programmer discovering Python
is a well-known pattern here - I even suspect it to be the most common
case !-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,083
Latest member
SylviaHarr

Latest Threads

Top