[BangPypers] how to override sys.stdin

2014-08-04 Thread Nitin Kumar
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 "", line 1,

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Dhruv Baldawa
On Mon, Aug 4, 2014 at 2:38 PM, Nitin Kumar wrote: > def readline(self): > print 'from fn readline',var > Where are you getting 'var' from? Shouldn't the method read as def readline(self, var)? -- Dhruv Baldawa (http://www.dhruvb.com) _

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Noufal Ibrahim KV
On Mon, Aug 04 2014, Nitin Kumar wrote: > Hi All, > > is there a way i can override raw_input or input function. Create a function like def my_input(prompt): # Your code here and then assign it to raw_input raw_input = my_input. [...] -- Cordially, Noufal http://nibrahim.net.in _

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Nitin Kumar
thats a typo error. in simple term my question would be: How to override sys.stdin. Nitin K On Mon, Aug 4, 2014 at 2:44 PM, Dhruv Baldawa wrote: > On Mon, Aug 4, 2014 at 2:38 PM, Nitin Kumar wrote: > > > def readline(self): > > print 'from fn readline',var > > > > Where are you g

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Noufal Ibrahim KV
On Mon, Aug 04 2014, Nitin Kumar wrote: > thats a typo error. > > in simple term my question would be: How to override sys.stdin. [...] The StringIO module gives you file like objects into which you can put data. They might work as substitues for sys.std* -- Cordially, Noufal http://nibrahim.n

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Rohit Chormale
Hi Nitin, Do u mean redirecting Standard IO streams? On Mon, Aug 4, 2014 at 3:08 PM, Noufal Ibrahim KV wrote: > On Mon, Aug 04 2014, Nitin Kumar wrote: > > > thats a typo error. > > > > in simple term my question would be: How to override sys.stdin. > > [...] > > The StringIO module gives you

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Rohit Chormale
It might work, sys.stdin = open(sys.stdin.fileno(), 'r', ) or Simply for replacing iostream, sys.stdin = open( ,'r') On Mon, Aug 4, 2014 at 3:48 PM, Rohit Chormale wrote: > > Hi Nitin, > > Do u mean redirecting Standard IO streams? > > > On Mon, Aug 4, 2014 at 3:08 PM, Noufal Ibrahim KV >

Re: [BangPypers] how to override sys.stdin

2014-08-04 Thread Saager Mhatre
On Mon, Aug 4, 2014 at 2:38 PM, Nitin Kumar wrote: > Hi All, > > is there a way i can override raw_input or input function. This sooo smells of the XY Problem . What are you really trying to do here? - d ___ BangPypers mai