LWN: Comments on "The (non-)return of the Python print statement" https://lwn.net/Articles/823292/ This is a special feed containing comments posted to the individual LWN article titled "The (non-)return of the Python print statement". en-us Sun, 19 Oct 2025 11:24:31 +0000 Sun, 19 Oct 2025 11:24:31 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net The (non-)return of the Python print statement https://lwn.net/Articles/826421/ https://lwn.net/Articles/826421/ flussence <div class="FormattedComment"> Python&#x27;s solution to the waterbed theory of language design seems to be to nail down the lumps.<br> </div> Sat, 18 Jul 2020 11:17:30 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/826064/ https://lwn.net/Articles/826064/ jezuch <div class="FormattedComment"> (To me that proposal sounded like &quot;we&#x27;ve created this problem for ourselves so let&#x27;s wade deeper into the weeds!&quot; Because language design is fun or something?)<br> </div> Tue, 14 Jul 2020 05:01:59 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/826063/ https://lwn.net/Articles/826063/ kenshoen Is it another deviation from <a href="https://www.python.org/dev/peps/pep-3099/">PEP3099</a>? <blockquote><ul><li>The parser won't be more complex than LL(1).</li></ul></blockquote> Tue, 14 Jul 2020 04:48:58 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825925/ https://lwn.net/Articles/825925/ nix <div class="FormattedComment"> Quite. As the proposal notes, people have been moving *towards* free functions for the cases considered, not away from them, so there&#x27;s no way they could be considered anything like deprecated.<br> </div> Sat, 11 Jul 2020 14:21:30 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825644/ https://lwn.net/Articles/825644/ kokada <div class="FormattedComment"> Yeah, I know, but having this in the language itself would be great.<br> </div> Thu, 09 Jul 2020 01:13:50 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825416/ https://lwn.net/Articles/825416/ niner <div class="FormattedComment"> In Raku you could use the compose function operator:<br> my &amp;composed = &amp;print ∘ &amp;fn2 ∘ &amp;fn1;<br> composed(foo);<br> <p> or directly:<br> (&amp;print ∘ &amp;fn2 ∘ &amp;fn1)(foo)<br> <p> Particularily handy in combination with the reduction meta operator [] when you have a list of functions:<br> my &amp;composed = [∘] @function-list; # i.e. @function-list[0] ∘ @function-list[1] ∘ @function-list[2] ...<br> composed foo; # because parentheses aren&#x27;t really needed anyway<br> </div> Mon, 06 Jul 2020 19:24:56 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825330/ https://lwn.net/Articles/825330/ NAR Elixir came to my mind as well when I read this article. It's <B>really</B> confusing when parenthesis are omitted, but I think that's what makes some Ecto code look like SQL, e.g. instead of this: <P> <CODE> query = from(c in City, select: {c.name, c.population}) </CODE> <P> one can write <P> <CODE> query = from c in City, select: {c.name, c.population} </CODE> Sun, 05 Jul 2020 19:58:53 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825331/ https://lwn.net/Articles/825331/ Cyberax <div class="FormattedComment"> This makes no sense at all. C++ is not Java and free functions are an integral feature. Especially since object methods can behave drastically differently from functions.<br> </div> Sun, 05 Jul 2020 19:48:26 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825329/ https://lwn.net/Articles/825329/ NAR <div class="FormattedComment"> Actually that weird C++ idea makes some sense, it&#x27;s too bad that C-compatibility (existence of free functions) causes problems decades later.<br> </div> Sun, 05 Jul 2020 19:46:32 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825305/ https://lwn.net/Articles/825305/ quotemstr <div class="FormattedComment"> Language designers sometimes, late in the evolution of their languages, propose the weirdest mechanisms. Here we have a function call syntax in Python that I couldn&#x27;t be more against. In C++-land, we have Bjarne Stroustrup&#x27;s weird idea [1] for a &quot;unified call syntax&quot;. Sometimes things are done and should be left alone.<br> <p> As for Python&#x27;s PEG parser: I really dislike this trend towards complicated and context-sensitive language grammars. I don&#x27;t want to have to backtrack across half a megabyte of crap to figure out what a token means. LALR is powerful enough to express anything you might reasonably want in a programming language. For God&#x27;s sake, let&#x27;s keep language grammars simple.<br> <p> [1] <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4474.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n...</a><br> </div> Sun, 05 Jul 2020 12:58:47 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825216/ https://lwn.net/Articles/825216/ xi0n <div class="FormattedComment"> You don’t even need to define partial(), as it’s already present in functools.<br> </div> Fri, 03 Jul 2020 16:22:16 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825203/ https://lwn.net/Articles/825203/ raoni <div class="FormattedComment"> I too have this instinct. Bu I think it is a typing mindset that is context dependent, when on shell or REPL you are on a &quot;bash&quot; mindset, that is different than when on an text editor.<br> </div> Fri, 03 Jul 2020 14:23:42 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825157/ https://lwn.net/Articles/825157/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Oh, with those non-parenthetical calls they almost pulled a Perl.</font><br> <p> Exactly <a href="https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it">https://en.wikipedia.org/wiki/There%27s_more_than_one_way...</a><br> <p> </div> Fri, 03 Jul 2020 10:04:00 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825149/ https://lwn.net/Articles/825149/ NYKevin <p>To be fair, GvR means "because we can <i>now</i>." In earlier Python 3.x, this was not possible. See for example <a href="https://github.com/python/cpython/blob/281cce1106568ef9fec17e3c72d289416fac02a5/Objects/exceptions.c#L2974">this code</a>, which is trying to decide whether or not the syntax error we are about to raise was caused by a 2.x-style print statement. <p>TL;DR: It's processing the code as a raw string, by hand. No AST, no tokenizer, just raw Unicode. It's mostly equivalent to <tt>grep -E '^[[:space:]]*print '</tt>. It should be entirely unsurprising that you can't "simply" convert this custom syntax error into a valid parse. Fri, 03 Jul 2020 05:52:55 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825146/ https://lwn.net/Articles/825146/ ibukanov <div class="FormattedComment"> Haskell does not have that problem as the language is lazy and functional. So there is no difference between a reference to a function or its result.<br> </div> Fri, 03 Jul 2020 03:45:53 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825143/ https://lwn.net/Articles/825143/ joey <div class="FormattedComment"> More like a Haskell really, but the non-tuples gave it away.<br> </div> Fri, 03 Jul 2020 01:34:00 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825083/ https://lwn.net/Articles/825083/ smitty_one_each <div class="FormattedComment"> See your Perl; raise you Visual Basic #ForTheWin<br> </div> Thu, 02 Jul 2020 13:57:19 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825081/ https://lwn.net/Articles/825081/ jafd <div class="FormattedComment"> Oh. I have a blind spot wherever those four letters are invoked.<br> </div> Thu, 02 Jul 2020 13:51:51 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825080/ https://lwn.net/Articles/825080/ dskoll <p>I know. I posted a link to a funny XKCD cartoon. Thu, 02 Jul 2020 13:49:47 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825075/ https://lwn.net/Articles/825075/ jafd <p>I'd rather have a demonstration of how one could, for example, create a new type of string — say I want to embed SQL which will get validated all over my codebase before my program even runs. </p> <pre> the_sql = sql"SELECT * FROM foobar WHERE (x = :placeholder)" </pre> <p>And if my little prerun hook is not present, the string is being treated as just string.</p> <p>Or make it HTML, or whatever else code or markup that you'd like to throw over the fence at another system.</p> <p>But for all gods' sake, let the print statement burn already. You Python people were putting it down for 12 years already, and it saddens me to no end that some people still can't let go of it.</p> Thu, 02 Jul 2020 13:43:58 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825072/ https://lwn.net/Articles/825072/ jafd <div class="FormattedComment"> In Perl, parentheses in function calls are optional.<br> <p> To pass an actual subroutine reference somewhere, you need to specify it as \&amp;foo.<br> </div> Thu, 02 Jul 2020 13:34:05 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825052/ https://lwn.net/Articles/825052/ dskoll <p><a href="https://xkcd.com/224/">What's that about Perl?</a> Thu, 02 Jul 2020 11:10:44 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825051/ https://lwn.net/Articles/825051/ rschroev <div class="FormattedComment"> Please no. Explicit is better than implicit. Python now makes a very clear distinction between just referring to a function (no parentheses), and calling a function (parentheses), unlike some other languages. I would hate to loose that.<br> <p> Just because you can do something, doesn&#x27;t mean you should..<br> </div> Thu, 02 Jul 2020 10:55:03 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825045/ https://lwn.net/Articles/825045/ mina86 <div class="FormattedComment"> First formatted strings, now attempt to allow function calls without parenthesises. It’s like they’re trying to tell us Perl was right all along. ;)<br> </div> Thu, 02 Jul 2020 10:11:15 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825039/ https://lwn.net/Articles/825039/ ragnar You could do something like this: <pre> def apply(first_arg, *args): res = first_arg for item in args: res = item(res) return res def partial(fn, *args): def _inner(*inner_args): return fn(*(args + inner_args)) return _inner apply('foo', len, partial(operator.mul, 7), print) </pre> Thu, 02 Jul 2020 09:25:31 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825038/ https://lwn.net/Articles/825038/ dw <div class="FormattedComment"> Eventually the kindest thing you can do for any old horse is to take it out back and shoot it.<br> </div> Thu, 02 Jul 2020 09:02:48 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825030/ https://lwn.net/Articles/825030/ NYKevin <div class="FormattedComment"> Haskell does that, but Haskell also automatically curries everything. Since Python has always had a strong difference between foo(bar, baz) and foo(bar)(baz), I doubt it would be a Good Idea.<br> </div> Thu, 02 Jul 2020 02:24:17 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825026/ https://lwn.net/Articles/825026/ ncm <div class="FormattedComment"> If the print function were to return itself, then we could have (had)<br> <p> <font class="QuotedText">&gt;&gt;&gt; print (2+2) 42</font><br> 4 42<br> <p> but no one would ever have wanted that.<br> </div> Thu, 02 Jul 2020 01:04:18 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825028/ https://lwn.net/Articles/825028/ kokada <div class="FormattedComment"> Glad this proposal didn&#x27;t gain track. Most languages that I know that allow calling functions without parenthesis (Ruby, Elixir) are either ambiguous causing unnecessary confusion (Ruby) or this is discouraged by the language users even if possible (Elixir).<br> <p> One case that I think having function without parenthesis helps is when you&#x27;re calling multiple functions, something like:<br> <p> print fn1(fn2(foo))<br> <p> But in this case, I really prefer thread macros instead:<br> <p> (-&gt; foo fn2 fn1 print)<br> <p> I would love if Python introduced something like above instead.<br> </div> Thu, 02 Jul 2020 01:03:24 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825023/ https://lwn.net/Articles/825023/ maney <div class="FormattedComment"> My first thought was along the lines of another comment here: we just got done with that conversion! But there is in fact one place that my fingers persist in wishing print statements were still a thing: when doing discovery/experimentation in the REPL. The things that were real warts (yeah &gt;&gt;filething, yuck) are non-issues there.<br> <p> Or maybe my fingers are just lazy - they keep trying to leave the parens off of dir, too. :-)<br> <p> </div> Thu, 02 Jul 2020 00:48:05 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825019/ https://lwn.net/Articles/825019/ roc <div class="FormattedComment"> Reintroducing print statements just after everyone had to finish converting their print statements to print functions is just rubbing salt in the wound.<br> </div> Thu, 02 Jul 2020 00:02:25 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825017/ https://lwn.net/Articles/825017/ kjp <div class="FormattedComment"> <font class="QuotedText">&gt; Van Rossum said there was an element of &quot;because we can&quot; to the idea;</font><br> <p> There is a whole lot of venting I could post in response to this right now, but I&#x27;m done. I&#x27;m just done. <br> <p> <p> <p> <p> </div> Wed, 01 Jul 2020 23:34:53 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825012/ https://lwn.net/Articles/825012/ jafd <div class="FormattedComment"> Oh, with those non-parenthetical calls they almost pulled a Perl.<br> <p> If the proposal got accepted, though, I&#x27;m wondering if there wouldn&#x27;t be an ambiguity if a function call was without arguments: is this a reference to the function itself or to its result? Or should we specify &amp;foo for the former, like, again, Perl?<br> </div> Wed, 01 Jul 2020 22:57:54 +0000 The (non-)return of the Python print statement https://lwn.net/Articles/825008/ https://lwn.net/Articles/825008/ benhoyt <div class="FormattedComment"> I&#x27;m very glad this change didn&#x27;t get any traction. Print being a statement (well, really being special) was an annoyance in Python 2, and makes much more sense as a plain old function in Python 3. It&#x27;d be weird to have two different ways to print stuff (with parens and without), and avoids the whole &quot;is it a tuple or are these function args?&quot;. I so much prefer &quot;print(&#x27;foo&#x27;, file=sys.stderr)&quot; over &quot;print &gt;&gt;sys.stderr, &#x27;foo&#x27;&quot;. And &quot;len &#x27;abc&#x27;&quot; ... that&#x27;s just crazy talk. :-)<br> </div> Wed, 01 Jul 2020 22:18:23 +0000