4 ms·
This shouldn't be downvoted, it's a legit question. I hear some people really really prefer `print as statement`, but I've never seem them in real life.
by RodericDay 9y ago
This shouldn't be downvoted, it's a legit question.
I hear some people really really prefer `print as statement`, but I've never seem them in real life.
- mixmastamyk 9y agoI do, but I understand the reasoning behind why it was changed. So I made a snippet in my editor and moved on with my life, haha. New print is now easier to to type than the old.
- seanp2k2 9y agoJust from __past__ import print_statement I really hope someone makes this work. I literally laughed and thought that it was a troll the first time I saw the future print import and that being used as a compelling reason that I should switch to Py3.
- mixmastamyk 9y agoConsistency and keyword args are useful.
- pishpash 9y ago"11. There should be one-- and preferably only one --obvious way to do it." from the Zen of Python. Somebody intentionally misread it as, "There should be only one way to do it." They obviously made a grave mistake. Same with many 2->3 changes.
- kevin_thibedeau 9y agoThe old way was foolishly inconsistent with the rest of the language. It only serves as an small expedient in the REPL.
- catdog 9y agoAlso from the Zen of Python: "Special cases aren't special enough to break the rules", the old print statement contains a lot of special syntax not found anywhere else in the language. Also "Readability counts", it's really obvious what print("foo", file=sys.stderr, end="") does instead of deciphering a construct like print >>sys.stderr, "foo", . Moreover you can pass a print function around, perform partial application, etc., a statement does not give you that.
- pishpash 9y agoYou prove nothing about why the two cannot co-exist in a non-regressive way. 'print' as a function already exists in Python 2, providing all the benefits you describe.
- pishpash 9y agoI stand very much corrected on the issue of 'print' and retract the above -- it only looks like a function syntactically in special (albeit, the most common) cases; PEP 3105 makes good points on how Python's parsing of whitespaces and parens renders a non-regressive parser out of reach. RTFM, I guess.
- deathanatos 9y agoI don't think print() is what I'd call "compelling", but I for one am quite glad to see this go: print "Text", For those not familiar with Python 2's syntax: that trailing comma is significant. And it's pure syntax; it's not the creation of a tuple either…
- deleted 9y ago[deleted]
- nayuki 9y agoIt gets weirder in the old syntax when you specify an output stream: print >>sys.stderr, "Spam" Whereas in the new print function it's a keyword argument: print("Spam", file=sys.stderr)
- comex 9y agoIt’s awful, especially since you can’t omit the space at the end. But the replacement, print(“Text”, end=“”) is verbose. Not too verbose, but considering how often I write prints as temporary throwaway code, every little bit hurts…
- deleted 9y ago[deleted]
- mark-r 9y agoI prefer print as a statement, just due to muscle memory - I keep forgetting to put in the parentheses. I'm sure I'll adjust eventually.