I'm writing a simple command line prompt script and noticed that lines printed immediately after doing a readline start with a leading space. Is there any way to avoid this behavior?
Sample function to demonstrate:
import sys
def foo():
print 'Enter some text.\n> ',
bar = sys.stdin.readline()[:-1]
print 'You entered "{0}"'.format(bar)
When I run this code I get:
>>> foo()
Enter some text.
> Hi
You entered "Hi"
^ the leading space I want to get rid of