[Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

boB Stepp robertvstepp at gmail.com
Tue Aug 1 22:03:54 EDT 2017


On Tue, Aug 1, 2017 at 8:25 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Steven D'Aprano <steve at pearwood.info> writes:
>
>> Its quite new. Up until recently, the documentation didn't distinguish
>> between function parameters which can take optional keywords and those
>> that can't.
>
> Where does the documentation describe this distinction? How is the
> reader, coming across a link to documentation for a function, expected
> to know what that symbol means in that context?

I also would like to know where this is documented.  The PEP Ben
linked to in his first response (PEP 457) is what I had looked at some
time in the past, but could not bring it to mind.  I obviously failed
the "expected to know ..." test, and I don't count myself a raw
beginner in Python anymore.  I imagine many would find the "/"
puzzling, perhaps even more experienced Python programmers?

> I am dismayed that the documentation has gone from describing function
> signatures in Python syntax, to describing function signatures that
> don't have the expected effect in Python code.
>
>     Python 3.6.2 (default, Jul 17 2017, 16:44:45)
>     [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> def foo(lorem, /, ipsum):
>       File "<stdin>", line 1
>         def foo(lorem, /, ipsum):
>                        ^
>     SyntaxError: invalid syntax

I gather from this example that "/" is *not* a syntactical element,
but is instead meant to augment natural English explanation.

Anyway, thanks very much Steve and Ben!

-- 
boB


More information about the Tutor mailing list