[BangPypers] how to override sys.stdin
Nitin Kumar
nitin.nitp at gmail.com
Mon Aug 4 11:08:48 CEST 2014
Hi All,
is there a way i can override raw_input or input function.
I tried with below code but getting error
import sys
class xyz(object):
def readline(self):
print 'from fn readline',var
sys.stdin = xyz
>>> raw_input('hi:')
hi:
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
raw_input('hi:')
TypeError: unbound method readline() must be called with xyz instance as
first argument (got nothing instead)
overriding sys.stdout is working fine.
Nitin K
More information about the BangPypers
mailing list