under naming

D

David Bear

I must have missed reading something important about naming conventions.

I have found that if I have a python module where I have an identifier named
with a beginning underscore that I cannot use from module import * to make
that name available in another module.

for example,
module A

_myvar = 'a local var'

module B
from A import *

_myvar -- is not available.

Is this in a pep somewhere ?
 
R

Robert Kern

David said:
I must have missed reading something important about naming conventions.

I have found that if I have a python module where I have an identifier named
with a beginning underscore that I cannot use from module import * to make
that name available in another module.

for example,
module A

_myvar = 'a local var'

module B
from A import *

_myvar -- is not available.

Is this in a pep somewhere ?

No; this has been a feature since before the time of PEPs. However, it is
documented here:

http://docs.python.org/ref/import.html

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
J

John Machin

David said:
I must have missed reading something important about naming conventions.

I have found that if I have a python module where I have an identifier named
with a beginning underscore that I cannot use from module import * to make
that name available in another module.

for example,
module A

_myvar = 'a local var'

module B
from A import *

_myvar -- is not available.

Is this in a pep somewhere ?

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

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top