why can't do foo = print ?
mfranklin1 at gatwick.westerngeco.slb.com
Thu Aug 1 12:12:23 CEST 2002
On Thursday 01 Aug 2002 10:09 am, Roman Yakovenko wrote:
> import sys
> -----Original Message-----
> From: Shagshag13 [mailto:shagshag13 at yahoo.fr]
> Sent: Thursday, August 01, 2002 10:56 AM
> To: python-list at python.org
> Subject: why can't do foo = print ?
> i would like to have something like :
> if output_is_file:
> fh = file(filename, 'w')
> write = fh.write
> write = print
> for i in something
so your code becomes....
fh = file(filename, 'w')
write = fh.write
write = sys.stdout
as sys.stdout is a file 'like' object.
More information about the Python-list