OK I repro the problem... here is what I have:*
*
*one.py*
from mayaPy import two

def func1():
print 'Calling function 1 of module two'
two.func1()

*two.py*
from mayaPy import three

def func1():
print 'Calling function 1 of module three'
three.func1()

*three.py*
*from mayaPy import one

def func1():
print 'Calling function 1 of module one'
one.func1()
*

Now in Maya calling :
*from mayaPy import one*
return this error:
*# ImportError: cannot import name one # *

so I need to rethink my structure or something....damn!

On Wed, Apr 22, 2009 at 3:04 PM, Sylvain Berger <[email protected]>wrote:

> yeah I have the empty __init__.py file in each folder.But the example you
> said doesn't work...
>
> everything worked fine until today.  I found this:
> I have this series of modules
>
> A import B
> B import C
> C import A
>
> now when I comment the  import B of the A module I don't get the import
> error.
>
> I tried to replicate the problem in simple module, but it does seem to
> replicate the problem...
>
>
> On Wed, Apr 22, 2009 at 2:47 PM, John Creson <[email protected]> wrote:
>
>> If you put an empty __init__.py file in each folder then each folder is
>> treated like a module
>>
>> so you could
>> import myPythonScript as mps
>> mps.modeling.pyScript1.myfunc()
>>
>>
>> //but I may be missing a bit in here
>>
>>
>>
>> On Wed, Apr 22, 2009 at 2:15 PM, sberger <[email protected]>wrote:
>>
>>>
>>> Hi, I have this folder structure where I put all my python scripts.
>>>
>>> myPythonScript
>>>  modeling
>>>  pyScript1.py
>>>  pyScript2.py
>>>  animation
>>>  pyScript1.py
>>>  shading
>>>  pyScript1.py
>>>  pyScript2.py
>>>  pyScript3.py
>>>  etc..
>>>
>>> In these script when I need a function from another script I import it
>>> like so:
>>> from myPythonScripts import pyScript1
>>> and I acces it like this:
>>> pyScript1.functionX()
>>>
>>> I seems to have hit a wall now because most of the script rely on
>>> other script. In each script I import another one, but I think I have
>>> a case where scriptA is importing scriptB and scritB is importing
>>> scriptA, thus causing a import error.
>>>
>>> I would like to know how I can setup my modules so that I can simply
>>> import everything once, and that each script can easily access script
>>> from a different folder.
>>>
>>> I hope my question makes sense.
>>>
>>> Thanks
>>>
>>>
>>>
>>
>> >>
>>
>
>
> --
> They say, "Evil prevails when good men fail to act." What they ought to say
> is, "Evil prevails."
> Nicolas Cage as Yuri Orlov in Lord of War.
>



-- 
They say, "Evil prevails when good men fail to act." What they ought to say
is, "Evil prevails."
Nicolas Cage as Yuri Orlov in Lord of War.

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to