Skip to content

Instantly share code, notes, and snippets.

@nnelluri928
Created September 29, 2021 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nnelluri928/45b13aeffa30284681b74f541ea87056 to your computer and use it in GitHub Desktop.
Save nnelluri928/45b13aeffa30284681b74f541ea87056 to your computer and use it in GitHub Desktop.
os module notes

In [22]: import os

In [23]: os.path.dirname("/Users/nnelluri/Desktop/nnelluri/python3-proj/add_device.py") Out[23]: '/Users/nnelluri/Desktop/nnelluri/python3-proj'

In [24]: import pathlib

In [25]: path=pathlib.Path("/Users/nnelluri/Desktop/nnelluri/python3-proj/add_device.py")

In [26]: path.parent Out[26]: PosixPath('/Users/nnelluri/Desktop/nnelluri/python3-proj')

In [27]: str(path.parent) Out[27]: '/Users/nnelluri/Desktop/nnelluri/python3-proj'

In [28]:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment