A little question about path of the file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

A little question about path of the file

Hi guys! I have a little question. Thank you in advance for your answers. I have a script (myprog.py) and imported module (mymodule.py) with some functions. I need to call a func in script from module which will return name of script. return __file__ - returns ...mymodule.py, but I need ...myprog.py to be returned. Example: === mymodule.py === def func(): return __file___ === myprog.py === from my module import func print(func()) # output will be:. .....mymodule.py # but I need: ....myprog.py

6th Oct 2017, 4:18 AM
Barmalew
1 Answer
0
try thi import mymodule.py as myprog.py this might work
6th Oct 2017, 5:01 AM
Asmit sharma
Asmit sharma - avatar