__file__
as others have said. You may also want to use os.path.realpath to eliminate symlinks:
import os
os.path.realpath(__file__)
More Related Contents:
- How do I create a python code that distinguishes between the capital of a state and the state that the capital has?
- How to name a file using a value in a list in a dictionary?
- How to copy files?
- Search and replace a line in a file in Python
- How do I get file creation and modification date/times?
- How to search and replace text in a file?
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python 3
- Reading a huge .csv file
- Selenium give file name when downloading
- How to make a Python script run like a service or daemon in Linux
- How to save a dictionary to a file?
- Do I understand os.walk right?
- How to get rid of double backslash in python windows file path string? [duplicate]
- How can I detect if a file is binary (non-text) in Python?
- Parse key value pairs in a text file
- Remove very last character in file
- In Python, is there a concise way of comparing whether the contents of two text files are the same?
- Easiest way to persist a data structure to a file in python?
- Copy multiple files in Python
- Is there a need to close files that have no reference to them?
- python copy files by wildcards
- Python: read all text file lines in loop
- Fastest way to write huge data in file
- Creating a new file, filename contains loop variable, python [duplicate]
- Reading integers from binary file in Python
- Who originally invented this type of syntax: -*- coding: utf-8 -*- [duplicate]
- create file of particular size in python
- Do files get closed during an exception exit?
- pickle – putting more than 1 object in a file? [duplicate]
- Use endswith with multiple extensions