-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???

Joe.DC
  • 11
  • 2
  • 2
    Please use english when posting on Stack Overflow. – JAL May 06 '16 at 16:04
  • If you need to use german language then have a look at [www.python-forum.de](https://www.python-forum.de). – Matthias May 06 '16 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 – Joe.DC May 06 '16 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! – Martin Bonner supports Monica May 06 '16 at 16:32
  • How are you running the script? If you are using nppexec, you can change the directory when the script is run. – Martin Bonner supports Monica May 06 '16 at 16:33
  • I use "run" -> "run external programm" (F5) in Notepad ++ In addition i did write the following in the line: (I read this in the internet) - cmd /k "C:\Python34\python.exe $(FULL_CURRENT_PATH)" - the /k has as a advantage that the cmd-window stays open Thank you (not using it too often...my English... just for scripting) – Joe.DC May 06 '16 at 16:37
  • I think you have to copy the lessons from your book to a working directory e.g. D:\python-scripts and please go deeper into nppexec for running python from Notepad++. See http://stackoverflow.com/questions/2392629/how-do-you-run-a-python-script-from-within-notepad and [Running Python Programs from Notepad++](https://www.youtube.com/watch?v=sJipYE1JT38) – help-info.de May 06 '16 at 16:40
  • I did paste it in German first and did translate it to English afterward... (just hit the "Enter-key"... in between... sorry) – Joe.DC May 06 '16 at 16:41
  • Ok, I have the NppExec installed... but I guess I am not using it correctly at the moment. Thank you for your answers! I will try to get into the "NppExec"-Tool... (Unvortunatelly there is no Youtube-Movie" ;-) ) Oh, I realised, I do not have the "NppExec" --> I will install it -> Thanks! – Joe.DC May 06 '16 at 16:44
  • Please note the YouTube link in my comment above. – help-info.de May 06 '16 at 17:16

1 Answers1

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)