Printing with raw_input

Peter Otten __peter__ at web.de
Mon Feb 15 05:11:20 EST 2010


Joan Miller wrote:

> Does `raw_input` uses internally `sys.stdout.write`?

You can test this yourself without reading the C source:

Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> class A:
...     def write(self, s):
...             sys.__stdout__.write(s.upper())
...
>>> sys.stdout = A()
>>> print "yadda"
YADDA
>>> raw_input("foo")
FOObar
'BAR'

Peter



More information about the Python-list mailing list