Print/Input statements
tre17 at student.canterbury.ac.nz
tre17 at student.canterbury.ac.nz
Tue Sep 21 20:46:35 EDT 1999
Andrew Stribblehill <a.d.stribblehill at dur.ac.uk> writes:
[slightly misunderstood version snipped]
>
> OK, a more obvious example (sorry!):
>
> #!/usr/bin/python
> import sys
> print "I didn't expect a Spanish Inquisition\n>",
> x=sys.stdin.readline()
> print "Nobody expects a Spanish Inquisition!"
>
> The "Nobody" has a space in front of it.
>
> When I replace the print statement with:
> sys.stdout.write("doodah\n>")
> the Nobody loses its annoying space.
>
> Cheerio,
>
> Andrew.
Well, you could always use raw_input to print your prompt, instead of
print:
#!/usr/bin/python
import sys
print "I didn't expect a Spanish Inquisition"
x = raw_input(">")
print "Nobody expects a Spanish Inquisition!"
If you also add `import readline' to the script (if readline is
available) then you get command editing and history.
--
Tim Evans
More information about the Python-list
mailing list