diff Python/bltinmodule.c @ 20307:aa681345bfab legacy-trunk

Implement isinstance(x, (A, B, ...)). Note that we only allow tuples, not other sequences (then we'd have to except strings, and we'd still be susceptible to recursive attacks).
author Guido van Rossum <guido@python.org>
date Sun, 07 Oct 2001 20:54:12 +0000
parents c082971823ce
children bbdc0abfbb13
line wrap: on
line diff
--- a/Python/bltinmodule.c	Sun Oct 07 11:44:49 2001 +0000
+++ b/Python/bltinmodule.c	Sun Oct 07 20:54:12 2001 +0000
@@ -1641,10 +1641,12 @@
 }
 
 static char isinstance_doc[] =
-"isinstance(object, class-or-type) -> Boolean\n\
+"isinstance(object, class-or-type-or-tuple) -> Boolean\n\
 \n\
 Return whether an object is an instance of a class or of a subclass thereof.\n\
-With a type as second argument, return whether that is the object's type.";
+With a type as second argument, return whether that is the object's type.\n\
+The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for\n\
+isinstance(x, A) or isinstance(x, B) or ... (etc.).";
 
 
 static PyObject *