[Python-ideas] Explicitly shared objects with sub modules vs import

Serhiy Storchaka storchaka at gmail.com
Sat May 30 18:13:44 CEST 2015


On 30.05.15 18:45, Ron Adam wrote:
>
> While trying to debug a problem and thinking that it may be an issue
> with circular imports,  I come up with an interesting idea that might be
> of value.  It wasn't a circular import problem in this case, but I may
> have found the actual bug sooner if I didn't need to be concerned about
> that possibility.
>
> I have had some difficulty splitting larger modules into smaller modules
> in the past where if I split the code by functionality, it doesn't
> correspond with how the code is organized by dependency.  The result is
> an imported module needs to import the module it's imported into.  Which
> just doesn't feel right to me.
>
> The solution I found was to call a function to explicitly set the shared
> items in the imported module.

Why not move all shared objects in common module? Then in both main and 
parse module you can write

from common import *




More information about the Python-ideas mailing list