Whats up with the _

Moshe Zadka moshez at math.huji.ac.il
Mon Feb 14 02:09:59 EST 2000


On Mon, 14 Feb 2000, JB wrote:

> I have some global vars defined in a module that are prefixed with an
> underscore '_'. When I do a 'from MyModule.MyModule import *' the vars
> with the _ prefix don't get imported but when I change the names to drop
> the _ they import properly. Is this a bug or a feature? If someone could
> expalin why this is so I would appreciate it. I missed this in the
> doc's.

It's a feature. I'm sure the eff-bot will pipe up with the url, but it's
a documented feature. It allows modules to have some weak privacy
constraints. This is essential to modules prepared for "from .. import *".

(For example, _test() in Tkinter)
--
Moshe Zadka <mzadka at geocities.com>. 
INTERNET: Learn what you know.
Share what you don't.





More information about the Python-list mailing list