[Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

boB Stepp robertvstepp at gmail.com
Sat Jan 23 14:17:16 EST 2016


On Sat, Jan 23, 2016 at 12:07 PM, Danny Yoo <dyoo at hashcollision.org> wrote:

> But Python has very little of this as a built-in part of the language.
> Guarding who gets to touch something is instead done by convention and
> by a very thin mechanism of name-mangling via an uncommonly-seen
> character, the underscore "_".
>
> For a little more discussion about this, we can see the Style
> Guidelines, around the part that talks about names:
>
>     https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles
>
> and we'll see a bunch of recommendations about using underscores for
> names when we want to provide a scoping hint to others.

One thing I was unaware of:

"_single_leading_underscore : weak "internal use" indicator. E.g. from
M import * does not import objects whose name starts with an
underscore."

My current understanding is to avoid "from M import *", but it is good
to know that this style of import will not capture names of the form
"_name".


-- 
boB


More information about the Tutor mailing list