Created
May 5, 2020 08:25
-
-
Save DavidMetcalfe/e582c6840518b0fe30f191128cdd9c4d to your computer and use it in GitHub Desktop.
Gets the location of the currently running Python script. Allows one to easily access files in the same directory as the script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
__location__ = os.path.realpath( | |
os.path.join(os.getcwd(), os.path.dirname(__file__))) | |
f = open(os.path.join(__location__, 'example.jpg')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
__location__ = os.path.realpath( | |
os.path.join(os.getcwd(), os.path.dirname(__file__))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment