Dear All,

Hello,

I am very new at python. I have an existing example project that have some scripts YYY,in path XXX/YYY and an script A.py that call these one by one.

i.e, YYY is colection of py files { y1.py, y2.py,....}, that are imported to A.py.
I mean that in A.py file we have this:

import XXX.y1 as Y1
Y1.doSomething1()
import XXX.y2 as Y2
Y2.doSomething2()

... and so,

I only want to add an script ZZZ.py to the YYY scripts in the XXX directory, so that call ZZZ.doSomething() after calling YYY.doSomething().

Although all y1.py,y2.py,... files in XXX directory are called in the same way, but when I add new python file in XXX directory, named it to ZZZ.py and change A.py to this:

import XXX.y1 as Y1
Y1.doSomething1()
import XXX.y2 as Y2
Y2.doSomething2()
import XXX.ZZZ as Z
Z.doSomething()

I got this error "python import error no module named XXX/ZZZ.py"
Python can not import ZZZ!
I wounder what is the difference between ZZZ.py and y1.py or y2.py,....

Why python can import XXX/YYY py files but returns this error for ZZZ.py?

Anybody could help me?

Thanks in advance.

OOOOOOOh! what a big mistake! I found it, Python import files from other directory! my example project install itself in the other path and i forgot about it!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.