Skip to content

Instantly share code, notes, and snippets.

@svenbrier
Last active August 28, 2022 15:48
Show Gist options
  • Save svenbrier/156ea2bc8fe5df4997decde1da5a8986 to your computer and use it in GitHub Desktop.
Save svenbrier/156ea2bc8fe5df4997decde1da5a8986 to your computer and use it in GitHub Desktop.
Get the file path with Python
import os.path
class File:
def __init__(self, file_name):
self.file_name = file_name
self.base_dir = ""
self.file_path = ""
def get_path(self):
self.base_dir = os.path.dirname(os.path.abspath(__file__))
self.file_path = os.path.join(self.base_dir, self.file_name)
return self.file_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment