Re: using names before they're defined
- From: "David Isaac" <aisaac0@xxxxxxxxxxx>
- Date: Wed, 26 Jul 2006 17:58:52 GMT
Suppose I have inherited the structure
PackageFolder/
__init__.py
mod1.py
SubPackageFolder/
__init__.py
mod2.py
mod3.py
When mod1 is run as a script,
I desire to import either mod2 or mod3 but not both
conditional on an option detected by the 'main()' function
in mod1.
Whichever is imported will be imported as, say, 'use_mod',
and code in mod1 will refer to use_mod.
Problem:
classes in mod1 that refer to 'use_mod' of course
raise a NameError, since the import does not take
place until 'main()' is run.
So, what is the right way to implement my desire?
Thanks,
Alan Isaac
.
- References:
- Re: using names before they're defined
- From: davehowey
- Re: using names before they're defined
- Prev by Date: Re: import from containing folder
- Next by Date: Re: Need a compelling argument to use Django instead of Rails
- Previous by thread: Re: using names before they're defined
- Next by thread: Re: using names before they're defined
- Index(es):
Relevant Pages
|
|