I'm not sure why you would need to, but you could always do this:
a = raw_input("Type something: ")
if sys.stdin is not sys.__stdin__:
print(a)
print("You typed in: "+a)
Then again, swapping raw_input
for your own implementation as needed would probably make more sense.
Edit: okay, based on your, comment it looks like you'll want to do some monkey patching. Something like this:
old_raw_input = raw_input
def new_raw_input(prompt):
result = old_raw_input(prompt)
if sys.stdin is not sys.__stdin__:
print result
return result
raw_input = new_raw_input
Of course, this might make the point of redirecting stdin moot.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…