I wrote a module module.py that I import in various scripts. The module has a function that needs the file path of the script main.py that it was imported by and do something with it. How do I get this file path?
module.py
def main_file_path():
print(way_to_acces_main_file_path)
is imported in
main.py
import module
module.main_file_path()
Running main.py should print the file path of main.py
main_file_path? This will also make it more reusable and generalized.module.pyalways needs the file path of the script that imports it, and this function already has a few parameters. I think adding the file path as parameter will complicate the function. I am looking for something like file that I can call in the module.