Re: piping out binaries properly

2005-10-12 Thread Paul Watson
"Andy Leszczynski" wrote in message news:[EMAIL PROTECTED] >I have got following program: > > import sys > import binascii > from string import * > sys.stdout.write(binascii.unhexlify("41410A4141")) > > > when I run under Unix I got: > > $ python u.py > u.bin > $ od -t x1 u.bin > 000 41 41 0a

Re: piping out binaries properly

2005-10-11 Thread Fredrik Lundh
Andy Leszczynski wrote: > when I run under Unix I got: > > $ python u.py > u.bin > $ od -t x1 u.bin > 000 41 41 0a 41 41 > > and under Windows/Cygwin following: > > $ python u.py > u.bin > $ od -t x1 u.bin > 000 41 41 0d 0a 41 41 > 006 > > The question is how can I pipe out binary cont

Re: piping out binaries properly

2005-10-11 Thread Paul Rubin
Erik Max Francis <[EMAIL PROTECTED]> writes: > > I've written lots of things whose standard out was designed > > specifically to be read by another program, but never as binary data. > > Plenty of applications use that functionality and depend on it. See > cjpeg, djpeg, the pbmplus library, and s

Re: piping out binaries properly

2005-10-11 Thread Mike Meyer
marduk <[EMAIL PROTECTED]> writes: > On Wed, 2005-10-12 at 00:16 -0400, Mike Meyer wrote: > [...] >> It's not normal to write binary content to stdout - you normally write >> it to a file. Open the file with open(name, 'wb') to write binaries. >> > > It is interesting that as a "Unix consultant"

Re: piping out binaries properly

2005-10-11 Thread Erik Max Francis
Mike Meyer wrote: > I watched the Unix world grow up, and it ain't normal to me. Since there's no distinction between a file opened in binary mode and in text mode on Unix, there is no difference. > I don't > think I've ever written a program that wrote binary data to standard > out, not in nea

Re: piping out binaries properly

2005-10-11 Thread Mike Meyer
Andy Leszczynski writes: > Mike Meyer wrote: >> It's not normal to write binary content to stdout - you normally write > > Well, I grew up in the Unix world and it is normal over there. I watched the Unix world grow up, and it ain't normal to me. I don't think I've ever written a program that wr

Re: piping out binaries properly

2005-10-11 Thread marduk
On Wed, 2005-10-12 at 00:16 -0400, Mike Meyer wrote: [...] > It's not normal to write binary content to stdout - you normally write > it to a file. Open the file with open(name, 'wb') to write binaries. > It is interesting that as a "Unix consultant" you should make that claim. Especially since

Re: piping out binaries properly

2005-10-11 Thread Andy Leszczynski
Mike Meyer wrote: > It's not normal to write binary content to stdout - you normally write Well, I grew up in the Unix world and it is normal over there. I am still curious which layer adds that 0xd. Is it python, cygwin, windows ... Thx for reply, Andy -- http://mail.python.org/mailman/listin

Re: piping out binaries properly

2005-10-11 Thread Mike Meyer
Andy Leszczynski writes: > I have got following program: > > import sys > import binascii > from string import * > sys.stdout.write(binascii.unhexlify("41410A4141")) > > > when I run under Unix I got: > > $ python u.py > u.bin > $ od -t x1 u.bin > 000 41 41 0a 41 41 > > and under Windows/Cygwi

piping out binaries properly

2005-10-11 Thread Andy Leszczynski
I have got following program: import sys import binascii from string import * sys.stdout.write(binascii.unhexlify("41410A4141")) when I run under Unix I got: $ python u.py > u.bin $ od -t x1 u.bin 000 41 41 0a 41 41 and under Windows/Cygwin following: $ python u.py > u.bin $ od -t x1 u.bi