[Tutor] telling dir(_builtins_) from dir(__builtins__)

Paul Sidorsky paulsid@shaw.ca
Thu, 14 Mar 2002 15:22:08 -0700


john public wrote:

> How in the heck is a Newwbie to know  dir(_builtins_) from
> dir(__builtins__)?!? both look like one hypen to me. One's just longer
> than the other. I just assumed it was a difference between the type on
> my machine and the type in the O'riely book. 

For stuff on your computer you can tell by attempting to select the
underscore(s) in question manually (i.e. by dragging your mouse over
it/them).  If you can't select a portion of a single line then it's a
single, otherwise it's got more than one.  Of course you usually have to
be expecting there to be more than one underscore before you try this. 
:-)

Not much you can do for printed material except hope that a good font is
chosen.  Though if it looks unusually long then it's probably two.  For
one you have to find a case where you know it's one and just remember
the length of the single in relation to the other characters.

(As an aside, this is one of the major reasons why I prefer the PC's
full-screen text mode.  My main text editor is still an old DOS editor
and I almost always use it full-screen.  It's virtually impossible to
make these kind of mistakes there.)

> I am sure glad
> I can ask you guys questions. This is exactly the kind of tedious
> dotting your I's and crossing your T's that drove me nuts years ago
> when I tried to learn basic but gave up. So far this is the first
> thing I have found like this in Python. 

To be blunt, that's what programming is, and why it's widely considered
to be such a difficult thing to do.  We have to be impeccably specific
because the computer can't figure out what we mean if we don't say it,
or say it wrong.  If you have difficulties being so finicky then you
will likely have great difficulty with programming.

That being said, Python certainly does have less syntactical pitfalls
and it's a lot easier to "speak" python (e.g. over the phone) than, say,
C.  So yeah, it's definitely easier to learn!  And as you said we are
here to help.

As for the choice of double-underscore, that's probably one of those
didn't-seem-like-a-problem-when-it-was-introduced-but-looking-back-
on-it-now-it-would-be-nice-if-it-were-done-differently things.  I don't
know the history of it, though.

-- 
======================================================================
Paul Sidorsky                                          Calgary, Canada
paulsid@shaw.ca                        http://members.shaw.ca/paulsid/