[Python-ideas] py3k: adding "print" methods to file-like objects
Erick Tryzelaar
idadesub at users.sourceforge.net
Thu Mar 13 21:56:20 CET 2008
This might be a minor thing, but I kind of wish that I could write this:
sys.stderr.print('first line')
sys.stderr.print('another line here')
sys.stderr.print('and again')
instead of:
print('first line', file=sys.stderr)
print('another line here', file=sys.stderr)
print('and again', file=sys.stderr)
As it's a lot easier to read for me. Of course you can always add
spaces to make the lines line up, but with a long print statement your
eye has to go a long distance to figure out what file, if any, you're
printing to. It could be pretty simple to add:
class ...:
def print(*args, **kwargs):
io.print(file=self, *args, **kwargs)
I haven't been able to find any discussion on this, has this already
been rejected?
More information about the Python-ideas
mailing list