In Python, OS module provides various functions to interact with the operating system. This module comes under the Python standard utility module, so there is no need to install it manually.
os.pardir is a constant string used by the operating system to refer to the parent directory. This method is also available via
os.pardir is ‘
.. for UNIX based OS and ‘
::‘ for Mac OS.
Return type: a string that refers to the parent directory.
Example 2: Let’s print the parent of current working directory.
Current Directory: /home/geeks/Desktop/gfg Parent Directory: /home/geeks/Desktop
Example 3: Getting the parent of specified path.
Path: your/path/for/parent/directory Parent: your/path/for/parent
- Python: os.path.abspath() method with example
- Understanding Python Pickling with example
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Common Operations on Fuzzy Set with Example and Code
- class method vs static method in Python
- Difference between Method Overloading and Method Overriding in Python
- Get() method for dictionaries in Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Line detection in python with OpenCV | Houghline method
- Python | os._exit() method
- Python | os.WEXITSTATUS() method
- Python | os.abort() method
- Python | os.renames() method
- Python | os.lseek() method
- Python calendar module | formatmonth() method
- Python | PyTorch sin() method
- Python | Sympy Line.is_parallel() method
- Python PIL | GaussianBlur() method
- Python | range() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nishkarsh146