3 ms·
That sys.stdout.write usage is interesting. Any reason for not just using print? Or if you want all of them on the same line, you can put a comma at the end o
by smtddr 13y ago
That sys.stdout.write usage is interesting.
Any reason for not just using print?
Or if you want all of them on the same line, you can put a comma at the end of print, like...
for q in range(10):
print q,
- GlitchMr 13y agoThis is Python 2, not Python 3.
- madcaptenor 13y agoI wanted to get everything on the same line; didn't realize the comma would do that.
- smtddr 13y agoUnderstood. Now that I think of it, I did the same thing until someone told me about the comma. Still though, the comma-trick puts spaces in between the numbers. I don't know how to get rid of that.
- michaelhoffman 13y agoYou can hack the internals like this: print q, sys.stdout.softspace = 0 But really, this wart is one of the reasons Python 3 has a new way of printing.