I have two folder A and B in a folder MAIN. In these two folders A and B there is two different python module ONE in A and TWO in B. Here ONE and TWO are two different python module in different folder. Actually I want to import the all facility from TWO to ONE. Then how can i do this? Please help me.....
Asked
Active
Viewed 15 times
0
-
Welcome to stackoverflow. Please refer https://stackoverflow.com/help/how-to-ask – bigbounty May 05 '19 at 12:32
-
Is the script you are running in folder A or in folder MAIN? Could you provide more detail on how the project is layed out and which scripts are running and importing from what. [This might help](https://stackoverflow.com/a/14132912/9590327) – Elephant May 05 '19 at 13:44
-
Actually my script is in folder A and folder A is inside Folder MAIN. Here MAIN is parent folder for A and B. – Himanshu sinha May 05 '19 at 13:46
-
So their is no script in the MAIN folder? I would suggest moving ONE into MAIN and then (with an empty __init__.py file in B) in A write `from B import TWO`. If there is a script in MAIN and ONE is imported into that script the same code should work. If this works I'll write a full answer on it explaining why – Elephant May 05 '19 at 18:18
-
But I don't want to do this. Actually I am working on a project and if I do so then my project layout will be lengthy to work. That's why I only do this that way – Himanshu sinha May 06 '19 at 15:53
-
Sorry then but the only other why I can think of is to use the absolute path [see this this answer](https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path). Although I cannot see why adding a script into main just saying `from A import ONE` would be a problem – Elephant May 08 '19 at 17:46