from future import pass_function

Chris Angelico rosuav at gmail.com
Thu Jul 26 05:53:20 CEST 2012


On Thu, Jul 26, 2012 at 1:30 PM, Ross Ridge <rridge at csclub.uwaterloo.ca> wrote:
> Steven D'Aprano  <steve+comp.lang.python at pearwood.info> wrote:
>>I can't believe I actually have to point this out explicitly, but pass is
>>not print. Apart from them both starting with the letter "P", they are
>>nothing alike. There are good reasons for making print a function, and
>>they don't apply to pass because pass doesn't do what print does.
>
> No, they're very much alike.  That's why all your arguments for print
> as function also apply just as well to pass a function.  Your arguments
> had very little to do what what print actually did.

Except that print / print() is executable. Execution proceeds through
your code, comes to a "print", and goes off to handle that, then comes
back to your code. But "pass" doesn't have code attached to it. Why
should it be a function?

One of the reasons for print becoming a function was its strange
collection of modifiers. How do you, with the print statement, send
output to someplace other than stdout? How do you make it not put a
newline? Far more logical to make those into keyword-only arguments to
a function, and far easier to later add more such options. What
parameters do you give to "pass"?

The pass keyword exists because Python can't have an empty pair of
braces, or an empty semicolon, to represent a "null statement". It
needs a keyword. That keyword is syntax, not code.

ChrisA



More information about the Python-list mailing list