[Tutor] Test for type(object) == ???
eryk sun
eryksun at gmail.com
Sat Feb 11 01:57:19 EST 2017
On Sat, Feb 11, 2017 at 6:22 AM, boB Stepp <robertvstepp at gmail.com> wrote:
> On Fri, Feb 10, 2017 at 11:49 PM, eryk sun <eryksun at gmail.com> wrote:
>
>> It's from the function's __text_signature__.
>>
>> >>> repr.__text_signature__
>> '($module, obj, /)'
>>
>> It means "obj" is a positional-only argument that cannot be passed as a keyword.
>
> [snip]
>
>> Look at open() for comparison.
>>
>> >>> open.__text_signature__
>> "($module, /, file, mode='r', buffering=-1, encoding=None,\n
>> errors=None, newline=None, closefd=True, opener=None)"
>
> In your comparison example, a forward slash appears again, but this
> time after "$module" in the location where "obj" previously appeared
> in the repr example. Is it indicating a similar use here?
All parameters listed before the slash are position-only. Everything
after the slash can be passed as a keyword argument.
> Can you provide a link to "__text_signature__" in the docs? I tried
> searching for it, but came up empty.
No, I can't. It was added in issue 19674.
http://bugs.python.org/issue19674
The '/' syntax for positional-only arguments is documented in PEP 457.
https://www.python.org/dev/peps/pep-0457
Also see the how-to for CPython's "Argument Clinic" preprocessor,
since (for now) positional-only arguments are only a concern for
built-in functions.
https://docs.python.org/3/howto/clinic.html
More information about the Tutor
mailing list