Multilingual
This week, I have written code in C#, C++, Managed C++, C, WiX, NAnt, ActionScript, VBScript, JScript, cmd batch, NMake, HTML, XSLT, and Ruby. And I will probably get some Python in before the weekend is over. <boggle/>
This week, I have written code in C#, C++, Managed C++, C, WiX, NAnt, ActionScript, VBScript, JScript, cmd batch, NMake, HTML, XSLT, and Ruby. And I will probably get some Python in before the weekend is over. <boggle/>
I've made some significant changes to my Python Batchfile Wrapper. The main virtue of this wrapper is that it finds python.exe and invokes it on the associated Python script, ensuring that input redirection works.
I've also adapted py2bat to work with my wrapper. I'm calling my version py2cmd.
Here's my latest batch file, which is shorter than its predecessor.
To use it, place it in the same directory as the Python script you want to run and give it the same basename; i.e., d:\some\path or other\example.cmd will run d:\some\path or other\example.py.
@echo off setlocal set PythonExe= set PythonExeFlags=-u for %%i in (cmd bat exe) do ( for %%j in (python.%%i) do…continue.
I've been getting into Python lately. One problem that I've encountered under Windows, is that input redirection doesn't work if you use the .py file association to run the script; e.g.:
C:\> foo.py < input.txt
There's a well-known input redirection bug. The fix is to explicitly use python.exe to run the script.
A related problem for me was that stdin was opened as a text file, not a binary file, so \r bytes were being discarded from binary input files. The fix is to run python.exe -u (unbuffered binary input and output).
I didn't want to hardcode the path to python.exe in a batch file, so I came up with the …continue.