On 01/-10/-28163 02:59 PM, Eric Snow wrote:
<snip>

Unfortunately not.  Most of this line of thinking is the result of
looking at import functionality in different ways, including with
regards to the problem of modules getting imported twice (once as
__main__).  I've been doing work on multi-file modules, custom module


Watch out for that importing of the original script. Doing that has many risks, only one of which is the problem of the two names.

In fact, any time you have mutual imports, you run a certain risk, if the modules involved have any code that's not inside defs. It's not well defined what order the initialisation happens, so you may wind up calling code in another module that's not really there yet.

The module import tree should be strictly hierarchical, without cycles. if you need stuff from the __main__, pass it to the other module, don't let the other module peek back over your shoulder.

In the case of a module importing things from your script, the solution is pretty simple. Move the needed code elsewhere, and import it both from your script and from the other module.

DaveA



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to