piping out binaries properly

Fredrik Lundh fredrik at pythonware.com
Wed Oct 12 08:54:33 CEST 2005


Andy Leszczynski wrote:

> when I run under Unix I got:
>
> $ python u.py > u.bin
> $ od -t x1 u.bin
> 0000000 41 41 0a 41 41
>
> and under Windows/Cygwin following:
>
> $ python u.py > u.bin
> $ od -t x1 u.bin
> 0000000 41 41 0d 0a 41 41
> 0000006
>
> The question is how can I pipe out binary content properly and platform
> independently?

$ python -h
usage: python [option] ... [-c cmd | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
...
-u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
...

</F>






More information about the Python-list mailing list