why can't do foo = print ?

Roman Yakovenko romany at actimize.com
Thu Aug 1 06:09:20 EDT 2002


Sure, 

import sys
sys.stdout.write("wer")

Roman

-----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 ?

hello,

i would like to have something like :

if output_is_file:
    fh = file(filename, 'w')
    write = fh.write
else:
    write = print

...

for i in something
    write(i)

how could i do that ? is this possible ? (i can't do "write = print" and don't understant why)

thanks in advance,

lt.


--
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list