On Jul 26, 7:08 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote:
> 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 b
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes:
> 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 th
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
bukzor <[EMAIL PROTECTED]> writes:
> I was trying to change the behaviour of print (tee all output to a
> temp file) by inheriting from file and overwriting sys.stdout
That's not what your code does, though.
> def main():
> n = notafile('/dev/stdout', "w")
Creates a new instance of the 'not