I want to customize the print statement in Python for additional text. But with my approach, it seems that the Enter key is getting buffered in the input.
The program I used is:
class rename_print: def __init__(self, stdout): self.stdout = stdout def write(self, text): self.stdout.write('###' + text) self.stdout.flush() def close(self): self.stdout.close() import sys prints = rename_print(sys.stdout) sys.stdout = prints print 'abc' The output I get is
###abc###
The output I expected is
###abc
What might be the reason of this? I doubt that input stream is getting buffered with the Enter key. How can I solve this issue?