Skip to content
  • Tutorials
    • c programming
      • libraries
    • c++
    • Linux
    • Python
    • batch programming
    • Technology
  • IDE
  • Tools
get self file name in python 1

get self file name in python

April 22, 2022 by Anurag batra
import os

os.path.basename(__file__)

Here is what the above code is Doing:
1. Importing the os module.
2. Storing the name of the current file in a special __file__ variable.
3. Printing the value stored in __file__ by accessing the basename attribute of the os.path module.

Categories Python Examples
Post navigation
how to download file from python
E: Unable to locate package python3-pip docker file
© MyEduKit - 2022 . All Rights Reserved.