Reputation: 1026
I think the title of the question is descriptive enough.
How can one find the location of the configuration file which is passed as an argument to a python script.
I would like to create a backup of the config file but copying it to another location.
Upvotes: 0
Views: 86
Reputation: 36
You can join current working folder to the argument path to get an absolute path.
import os
import sys
if len(sys.argv) > 1:
full_path = os.path.join(os.getcwd(), sys.argv[1])
print(full_path)
Upvotes: 2