How do I find the directory of the running Python script from inside Python [3.3]? http://stackoverflow.com/questions/4934806/python-how-to-find-scripts-directory http://stackoverflow.com/questions/4934806/python-how-to-find-scripts-directory
The closest I have got to the answer is: sys.argv[0] , but that still includes the file name, so I cannot use it. Is there any other way?
NOTE: I am fairly new to Python.
Here is some code I have made so far (the part where it says rundir = sys.argv[0] is where the suggested code will go):
import pygame from pygame.locals import * import os, sys import time pygame.init() import statuscheck print("Completed program status check.") import mods.modlist print("Loaded all mods..") print("Completed loading") sys.dont_write_bytecode = True rundir = sys.argv[0] print("Running from" + rundir)