[Tutor] Test for type(object) == ???
boB Stepp
robertvstepp at gmail.com
Sat Feb 11 01:22:50 EST 2017
On Fri, Feb 10, 2017 at 11:49 PM, eryk sun <eryksun at gmail.com> wrote:
> On Sat, Feb 11, 2017 at 3:22 AM, boB Stepp <robertvstepp at gmail.com> wrote:
>>
>> py3: help(repr)
>> Help on built-in function repr in module builtins:
>>
>> repr(obj, /)
>> Return the canonical string representation of the object.
>>
>> For many object types, including most builtins, eval(repr(obj)) == obj.
>>
>> Question: What does the forward slash represent in this context?
>
> 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?
Can you provide a link to "__text_signature__" in the docs? I tried
searching for it, but came up empty.
--
boB
More information about the Tutor
mailing list