[Python-Dev] [PEP 214] FW: sys.stndout syntax (original) (raw)
Tim Peters tim_one@email.msn.com
Fri, 18 Aug 2000 17🔞56 -0400
- Previous message: [Python-Dev] Adding more LANG support to locale.py (Re: gettext in the standard library)
- Next message: [Python-Dev] [PEP 214] FW: sys.stndout syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
For those of you who stopped reading comp.lang.python, note that this is typical of the advice users get in the absence of syntactic "print" sugar.
it's-not-exactly-intuitive-that-a-"print"-stmt-isn't-meant-to- do-output-ly y'rs - tim
-----Original Message----- From: python-list-admin@python.org [mailto:python-list-admin@python.org]On Behalf Of Jeff Kunce Sent: Friday, August 18, 2000 3:41 PM To: python-list@python.org Subject: Re: sys.stndout syntax
on win32, to get printed output to a file i use >>> sys.stndout = open('file.txt', 'w') how do i get it to go back to the command line
#Here is the specific solution for those who remember the secret password: sys.stdout = open('file.txt', 'w') print 'this is written to file.txt' sys.stdout.close() sys.stdout = sys.stdout print 'this is written to console'
#Here is the general solution if you can't be bothered with remembering secret passwords: original_stdout = sys.stdout sys.stdout = open('file.txt', 'w') print 'this is written to file.txt' sys.stdout.close() sys.stdout = original_stdout print 'this is written to console'
--Jeff
-- http://www.python.org/mailman/listinfo/python-list
- Previous message: [Python-Dev] Adding more LANG support to locale.py (Re: gettext in the standard library)
- Next message: [Python-Dev] [PEP 214] FW: sys.stndout syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]