-1

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\05_Python_Project\Python_von_Kopf__\chapter7\webapp-chapter7\cgi-bin\some_file.txt"

I want to a write just a short filename like:

with open ('some_file.txt') as footer_d:
    ...

I realise that Notepad++ is searching in the following path: "C:\Program Files (x86)\Notepad++"

Can I somehow change/ configure Notepad++ for searching at the file location???

10
  • 2
    Please use english when posting on Stack Overflow. Commented May 6, 2016 at 16:04
  • If you need to use german language then have a look at www.python-forum.de. Commented May 6, 2016 at 16:26
  • 1
    changed it to English language... my English is unvortunatelly not this good. But hope you can figure it out (the question might not be to difficult). Dan Commented May 6, 2016 at 16:29
  • 1
    Hmm. Your English is fine. It's better than my German, and I have been working in a German speaking office for the last eight months! Commented May 6, 2016 at 16:32
  • How are you running the script? If you are using nppexec, you can change the directory when the script is run. Commented May 6, 2016 at 16:33

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.