3

I have a small (self-written) python script located in, let's say, C:\dummy\myscript.py. In my Windows 7 terminal, I can call this script with either one of the following three commands. They all work.

C:\dummy>python myscript.py
C:\dummy>myscript.py
C:\dummy>myscript

I understand that the latter two commands work out fine because of the correct assoc .py=Python.File setting on my system(see here)

However, when I am in another folder, say, C:\dummy\subfolder\, it only works when I prepend the python executable.

C:\dummy\subfolder>python ../myscript.py

C:\dummy\subfolder>../myscript.py                         <-- doesn't work
'..' is not recgnized as an internal or external command,
operable program or batch file.

C:\dummy\subfolder>../myscript                            <-- doesn't work
'..' is not recgnized as an internal or external command,
operable program or batch file.

Why doesn't it work in the other two cases?

1 Answer 1

4

You're using *nix path delimiters. Use ..\myscript.py, not ../myscript.py. The Python program is smart enough to accept either.

C:\Program Files (x86)\Notepad++\localization>../notepad++.exe
'..' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files (x86)\Notepad++\localization>..\notepad++.exe
[ this one launched the app as expected ]
2
  • Ah rats, of course! Feb 20, 2014 at 14:19
  • 2
    @Rabarberski Just a note that this is the case for CMD; PowerShell can take either delimiter.
    – Rynant
    Feb 20, 2014 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.