[Tutor] Test for type(object) == ???

boB Stepp robertvstepp at gmail.com
Fri Feb 10 22:22:57 EST 2017


On Fri, Feb 10, 2017 at 7:50 PM, Zachary Ware
<zachary.ware+pytut at gmail.com> wrote:

> Try `help(repr)` and `int` on its own at the interactive prompt, and

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?  If I type:

py3: repr(int, /)
  File "<stdin>", line 1
    repr(int, /)
              ^
SyntaxError: invalid syntax

whereas:

py3: repr(int)
"<class 'int'>"

appears to be correct.

-- 
boB


More information about the Tutor mailing list