Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using ~ for home directory

Status
Not open for further replies.

IPGuru

Vendor
Jun 24, 2003
8,391
GB
I am writing myself a small utility to copy & rename files from my camera.

to ensure I don't overwrite an existing file I am trying to see if it already exists using os.path.exists(<filename>

but if the file name is of the format "~/<directory>/<filename>" it always returns false.

I would like to configure this a a default path so it will work for multiple users on my system.

Any Ideas as to why ~/ is not working correctly?


 
Found the answer os.path.expanduser(<filename>)

GIMF :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top