You can use __file__
to get the name of the current file. When used in the main module, this is the name of the script that was originally invoked.
If you want to omit the directory part (which might be present), you can use os.path.basename(__file__)
.
More Related Contents:
- Using python to extract out data from excel csv file [closed]
- How do I get the path and name of the file that is currently executing?
- How to execute Python scripts in Windows?
- Python recursive folder read
- How can I sandbox Python in pure Python?
- How to make a Python script run like a service or daemon in Linux
- Driving Excel from Python in Windows
- Why the Global Interpreter Lock?
- How do I abort the execution of a Python script? [duplicate]
- Loading external script with jinja2 template directive
- Purpose of #!/usr/bin/python3 shebang
- Checking if a website is up via Python
- Batch equivalent of “source” on Windows: how to run a Python script from a virtualenv
- Using lambda function in python
- How to make function decorators and chain them together?
- Creating a singleton in Python
- urllib2.HTTPError: HTTP Error 403: Forbidden
- How to retrieve the values of dynamic html content using Python
- How can I obtain the element-wise logical NOT of a pandas Series?
- Dead simple example of using Multiprocessing Queue, Pool and Locking
- How to implement custom indentation when pretty-printing with the JSON module?
- Assigning string with boolean expression [duplicate]
- PyCharm error: ‘No Module’ when trying to import own module (python script)
- Site matching query does not exist
- How to read contents of 7z file using python
- How to check if a user is logged in (how to properly use user.is_authenticated)?
- TypeError: ‘builtin_function_or_method’ object is not subscriptable
- Return multiple columns from pandas apply()
- PyQt: How to hide QMainWindow
- How can I call ‘git pull’ from within Python?