Skip to content Skip to sidebar Skip to footer

Relative Path For Python With Notepad++

I am using: Notepad++, Python 3.4, Windows 7 I've got the following problem: If I want (for example) to open a file. I always have to put in the whole path for example 'C:\Python34

Solution 1:

A very simple way to implement this, is to do it all in Python:

import os

os.chdir("C:/Python34/05_Python_Project/Python_von_Kopf__/chapter7/webapp-chapter7/cgi-bin")

(The Windows API is quite happy with forward slashes as a path separator. It's command line applications that tend not to like them.) Alternatively:

dirlist = ["C:\\", "Python34", "05_Python_Project", Python_von_Kopf__",
           "chapter7", "webapp-chapter7", "cgi-bin"]
dir = os.path.join(*dirlist)
os.chdir(dir)

Post a Comment for "Relative Path For Python With Notepad++"