2.1.1 global weirds
Just van Rossum
just at letterror.com
Sat Aug 11 07:30:49 EDT 2001
Robin Becker wrote:
> I have difficulty in understanding why the
> print n, len(getStory()), len(_story)
> always prints n, 0, 0
>
> why is b2.getStory not getStory? Is it because importing from a isn't
> the same as the importing from the __main__ module?
Exactly. The script is implicitly the __main__ module, and "import a"
results in a new module.
> What is the correct way to import from the main script?
"import __main__" should work, but I'm not sure that's a wise thing to do...
Just
More information about the Python-list
mailing list