Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can someone tell me about...

Skip to first unread message

Kia Arab

unread,
Apr 18, 2000, 3:00:00 AM4/18/00
to
variable names that start an underscore "_".

Interactively, python will recognize a variable name that begins with
one underscore (_myVar). The variable naming rules even say that is
acceptable.

However, when I try to use it in a module, it bombs.

What's the deal?

Robin Dunn

unread,
Apr 18, 2000, 3:00:00 AM4/18/00
to

> Interactively, python will recognize a variable name that begins with
> one underscore (_myVar). The variable naming rules even say that is
> acceptable.
>
> However, when I try to use it in a module, it bombs.
>

When you say "use it in a module" do you mean like this:

from the_module import *
print _myVar

If so then that is normal as names begining with an underscore are not
imported with the *, (it's a way to help prevent namespace pollution.) On
the other hand, this should work:

import the_module
print the_module._myVar


--
Robin Dunn
Software Craftsman
ro...@AllDunn.com
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/ Check it out!


Fredrik Lundh

unread,
Apr 18, 2000, 3:00:00 AM4/18/00
to
Kia Arab <ka...@stsci.edu> wrote:
> variable names that start an underscore "_".
>
> Interactively, python will recognize a variable name that begins with
> one underscore (_myVar). The variable naming rules even say that is
> acceptable.
>
> However, when I try to use it in a module, it bombs.

"bombs"?

> What's the deal?

lousy subject line, no code sample, no error message,
vague description of the actual problem.

but alright, I'll guess: when you read this page:

http://www.python.org/doc/current/ref/import.html

you missed the following sentence:

If the list of identifiers is replaced by a star ("*"), all
names defined in the module are bound, except those
beginning with an underscore ("_").

</F>

Kia Arab

unread,
Apr 18, 2000, 3:00:00 AM4/18/00
to

Robin,

Thanks for clearing that up.

Moshe Zadka

unread,
Apr 19, 2000, 3:00:00 AM4/19/00
to Kia Arab
On Tue, 18 Apr 2000, Kia Arab wrote:

> variable names that start an underscore "_".
>
> Interactively, python will recognize a variable name that begins with
> one underscore (_myVar). The variable naming rules even say that is
> acceptable.
>
> However, when I try to use it in a module, it bombs.

Please give an example of the "bombinh". I suspect you do
"from module import *".

Solutions:

a) don't do it
b) read the language ref. about from module import *, and names that begin
with underscore.
--
Moshe Zadka <mza...@geocities.com>.
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com

0 new messages