1

on Windows it's possible to run a python script >like_so.py, with the help of the Python launcher for Windows and file associations.

here's two line python script, like_so.py:

import sys
print(sys.argv[0])

on unix when running it $./like_so.py from the terminal, the output is ./like_so.py

is the behavior consistent on Windows?

when running it on Windows >like_so.py is the output like_so.py?

Wis
  • 484
  • 7
  • 22
  • No, the command line template is `py.exe "%1" %*`, where `%1` gets replaced by the fully-qualified path of the target file and `%*` contains any command-line arguments. – Eryk Sun Apr 07 '19 at 07:45
  • thanks, why not an answer though? is it not really a programming question? should I delete it? – Wis Apr 07 '19 at 07:49
  • Could you elaborate on the reason it matters? Or is this just a question for its own sake? – Eryk Sun Apr 07 '19 at 07:50
  • should I remove the last sentence from my previous question, because it's unix specific? https://stackoverflow.com/questions/55555882/how-to-get-the-script-path-of-a-python-process-whos-cmdline-is-python-with – Wis Apr 07 '19 at 07:52
  • looks like I should, because the issue concerning that question is unix-specific, because on windows a process's commandline is never .py, right? – Wis Apr 07 '19 at 08:12
  • If run directly, the commandline can be `"python<.exe>" "script.py"`. But if run via the file association -- given the default configuration for the py launcher -- it will always be fully-qualified for both the executable and the script, i.e. `"path/to/python.exe" "path/to/script.py"`. – Eryk Sun Apr 07 '19 at 08:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/191387/discussion-between-wis-and-eryksun). – Wis Apr 07 '19 at 08:22

0 Answers0