why can't do foo = print ?

Shagshag13 shagshag13 at yahoo.fr
Thu Aug 1 04:55:44 EDT 2002


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.





More information about the Python-list mailing list