Is it possible to read stdin as binary data in Python 2.6? If so, how?
I can see in the Python 3.1 documentation that this is fairly simple, but the possibilities for this do not seem to exist in 2.6.
If the methods described in 3.1 are not available, is there a way to close stdin and reopen in binary mode?
Update
Just to be clear, I use the βtypeβ in the MS-DOS shell to pass the contents of the binary into my python code. As I understand it, this should be the equivalent of the "cat" Unix command. But when I check this, I always get one byte less than the expected file size.
Update # 2
First of all, thanks for all the answers. I am slowly working on a real, useful solution. In the end, I'm still trying to create a standalone JAR file that runs my Python code, automatically passing through all the command line arguments that are not corrupted.
The reason I go along the Java / JAR / Jython route is because one of my main external libraries is only available as a Java JAR. But, unfortunately, I started my work as Python. It might have been easier to convert my code to Java some time ago, but since this material was supposed to be compatible, I decided that I would try to go through it and prove that it can be done.
In case someone wondered, this is also related to the question that I asked a few days ago.
Packaging and Deploying Jython from Eclipse
This question was answered by question .
So, I will try to update my original question with some notes about what I have understood so far.
thebeav May 17 '10 at 16:34 2010-05-17 16:34
source share