Write binary data to standard error?

Saptarshi saptarshi.guha at gmail.com
Thu Aug 13 04:44:38 CEST 2009


On Aug 12, 10:32 pm, sapsi <saptarshi.g... at gmail.com> wrote:
> Hello,
> This is probably a basic question, but how does one write binary data
> to standard error e.g int as network order (4 bytes)?
>
> Much thanks
> Saptarshi

Solved:
import sys
import os
from struct import *

d=os.fdopen(sys.stderr.fileno(),"wb")
d.write("\x00")
d.write(pack(">i",5))



More information about the Python-list mailing list