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?
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!
"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>
Thanks for clearing that up.
> 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