Dietrich Bollmann wrote:
I am trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
Yes
How can I get rid of the blank?
By not asking for it with the comma.
while (1):
... print "$ ",
... input = sys.stdin.readline()
... input = input.strip()
... print input
... print input
... print input
...
$ one
The one and \n above are from stdin, not stdout. So stdout thinks
it is still on the same line as the $.
one
The space separates the 'one' from the '$ ' that it output to stdout
above.
one
one
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list