On Sat, 26 Jul 2008 14:07:52 +1000 Ben Finney <[EMAIL PROTECTED]> wrote: > > sys.stdout = n > > Re-binds the name 'sys.stdout' to the object already referenced by the > name 'n'. No objects are changed by this; only bindings of names to > objects.
I do agree that the object formerly known as sys.stdout hasn't changed. > > print "Testing: 1, 2, 3..." > > Doesn't rely at all on the name 'sys.stdout', so isn't affected by all > the binding of names above. Hmm. Are you saying that the following doesn't work? $ python >>> f = open("test", "w") >>> import sys >>> sys.stdout = f >>> print "test message" >>> sys.exit(0) $ cat test test message > In other words, you can't change the object used by the 'print' > statement only by re-binding names (which is *all* that is done by the > '=' operator). Apparently I can. > You can, however, specify which file 'print' should use > <URL:http://www.python.org/doc/ref/print.html>. Which contains this statement. "Standard output is defined as the file object named stdout in the built-in module sys." I suppose that there might be some ambiguity there but the proof, as they say, is in the pudding. -- D'Arcy J.M. Cain <[EMAIL PROTECTED]> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list