[Tutor] Which is better Practice and why

eryksun eryksun at gmail.com
Mon Oct 22 17:32:35 CEST 2012


On Mon, Oct 22, 2012 at 11:14 AM, eryksun <eryksun at gmail.com> wrote:
>
> Just to clarify that I'm following you, would you count the following
> as a script importing itself 'indirectly'?
>
> Assume two modules in the same directory, mod1.py and mod2.py, can
> both act as the main entry point, and both import each other (assume
> no circular import problem). Then if mod1.py runs as __main__ and
> imports mod2, and mod2.py imports mod1, there are 2 copies of the
> classes and functions defined in mod1.py. For example, there's
> __main__.MyError vs mod1.MyError.

I forgot to specify that __main__ can reference mod1 via mod2.mod1, so
my question is if this indirection via mod2 is what you meant by
importing itself 'indirectly'. Thanks.


More information about the Tutor mailing list