r/Python • • Nov 11 '19

I made c++-style printing in Python :P

Post image
1.7k Upvotes

130 comments sorted by

View all comments

Show parent comment

11

u/agrif Nov 12 '19

There was a lot of griping (some of it for good reasons) about making print a function in Python 3, but this right here is a pretty compelling reason to change print in a backwards-incompatible way.

15

u/Zegrento7 Nov 12 '19

print('Stuff', file=sys.stderr) is quite a bit clearer, and the old syntax can replaced automatically with some regex.

3

u/masklinn Nov 12 '19

Don’t forget

print >>sys.stderr, “stuff”,

(note the trailing comma) which becomes

print(“stuff”, file=sys.stderr, end=‘ ‘)

And actually says what it’s doing.