Python __file__
The __file__
attribute in Python is a built-in variable that represents the path of the Python script that is currently being executed. It provides the absolute path of the script, including the script's name.
Here's an example:
print(__file__)
Output:
/path/to/my_script.py
Note that the __file__
attribute is not available in the interactive Python shell (repl) as there is no script being executed.