Q: raw stdin/out on WIN32?

Yann SAMAMA ysamama at cybercable.fr
Tue Mar 14 18:51:34 EST 2000


Hi all!!

I want to write for WIN32 platforms a tiny script similar to "split" on
UNIX.
for example :
python split.py -s 100 < bigfile
=> splits the input (here, bigfile) in 100 kb files
python split.py > bigfile
=> concatenates every contiguous files named split.<n> to standard output
I've understood so far that I need to *redefine* stdin/stdout tu be used in
binary mode.
I've found this in Deja.com :

if sys.platform == "win32":
    import msvcrt
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # here is the exception
raised

 but it raises an IOError exception...

Traceback (innermost last):
  File "C:\WINDOWS\BUREAU\split.py", line 209, in main
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
IOError: (9, 'Bad file descriptor')

So where do I miss the point?

Any clue really welcomed!

Totally lost-ly yours,

Yann.





More information about the Python-list mailing list