Is there a way to get the python output in the shell from where i call the script?
(Calling with the script name only, eg. PS>myscript.py
)
More generally phrased: Is there a way to make > myscript.py
behave like python myscript.py
?
And: What's the difference of what happens in the two cases? Why is calling the script directly being executed by a separate python process, and not as a subprocess within the shell?
(That assumption of what's happening is probably wrong in concept and in wording, but i think that's what is happening.)
Why i bother:
In PowerShell (or CMD), i can run PS>myscript.py
from anywhere, because i added it's path to the PATH environment variable.
Problem is, it will open a new window, that closes after execution. So i can't see the script output afterwards.
My first idea, calling python myscript.py
needs more typing and more importantly, works only if myscript.py is a full path.
A workaround to that would be to add the script to Python's modules path PYTHONPATH and then call it as a module: python -m myscript
, but that's still more typing and more to remember, so still a workaround.