Re: Safely dealing with arbitrary file objects

2007-10-14 Thread Paul Hankin
On Oct 14, 5:01 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I have found myself writing functions rather like these: > > def openfile(filename): > if filename == '-': > # convention for shell scripts in Unix-land is to use > # '-' for stdin/stdout for rea

Re: Safely dealing with arbitrary file objects

2007-10-14 Thread Scott David Daniels
Steven D'Aprano wrote: > I have found myself writing functions rather like these: > > def openfile(filename): > if filename == '-': > # convention for shell scripts in Unix-land is to use > # '-' for stdin/stdout for reading/writing. > outfile = sys.stdout > if file

Safely dealing with arbitrary file objects

2007-10-14 Thread Steven D'Aprano
I have found myself writing functions rather like these: def openfile(filename): if filename == '-': # convention for shell scripts in Unix-land is to use # '-' for stdin/stdout for reading/writing. outfile = sys.stdout if filename == '2-': outfile = sys.std