Reputation: 1
I am defining a new Python pipeline for Maya 2012 and I am having difficulty setting up package properly.
I have:
Prod
__init__.py
PackA
__init__.py
PAMod1.py
PackB
__init__.py
PBMod2.py
PAMod1
def a():pass
PAMod2
def b():pass
How do I call PAMod1.b
in PAMod2.b
?
How do I call module with the whole name Prod.PackA.PAMod1.a()
inside PAMod2.b
?
Upvotes: 0
Views: 328
Reputation: 12218
as long as Prod is on the python path, you can do this - the safest way, using absolute paths
# in PAMod2.py
import Prod.PackA.PAMod1
Prod.PackA.PAMod1.Function()
or (still safe, easier to type):
# in PAMod2.py
import Prod.PackA.PAMod1 as Mod1
Mod1.Function()
You can reference a sibling package as well. This only works inside a module - you can'd do it interactively ( ie, from the maya script editor) . It's also a going to break if eather PackA or PackB moves
# in PAMod2.py
from .. import PAMod1
PAMod1.Function()
The python docs are here and this is a good SO question on the same (common) topic
Upvotes: 2