Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...isinstance(x, C) returns true iff x is an instance of C or of a (direct or indirect) subclass of C. The first argument may hyave any type; if x is not an instance of any class, isinstance(x, C) always returns false. The second argument must be a class object. Sequence Unpacking Previous Python versions require an exact type match between the left hand and right hand side of "unpacking" assignments, e.g. (a, b, c) = x requires that x is a tuple with three items, wh...
...isinstance(x, int). Which reminds me. The second argument of isinstance() may now be a tuple of classes or types. For example, isinstance(x, (int, long)) returns true when x is an int or a long (or an instance of a subclass of either of those types), and similarly isinstance(x, (str, unicode)) tests for a string of either variety. We didn't do this to isclass(). Introspecting instances of built-in types For instances of built-in types (and for new-style classes in general), x....
...isinstance(x, int). Which reminds me. The second argument of isinstance() may now be a tuple of classes or types. For example, isinstance(x, (int, long)) returns true when x is an int or a long (or an instance of a subclass of either of those types), and similarly isinstance(x, (str, unicode)) tests for a string of either variety. We didn't do this to issubclass(). (Yet. It was done to issubclass() in Python 2.3.) Introspecting instances of built-in types For instances of bui...
...isinstance(x, basestring). bool, True, False - these were introduced as ints in Python 2.2.1, but are now a separate type (a subtype of int). This means that True and False are now printed as the strings 'True' and 'False', respectively. As of 2.3b1, bool() without arguments returns False. (PEP 285) compile(), eval(), exec - fully support Unicode, and no longer issue a SyntaxError when their input doesn't end with a newline. (New in 2.3a2.) range() - as of 2.3b1 supports long arguments with a...
...isinstance(x, y) now also succeeds when y is a type object and type(x) is y. repr() and str() of class and instance objects now reflect the package/module in which the class is defined. Module "ni" has been removed. (If you really need it, it's been renamed to "ni1". Let me know if this causes any problems for you. Package authors are encouraged to write __init__.py files that support both ni and 1.5 package support, so the same version can be used with Python 1.4 as well a...
...isinstance() and issubclass() by 50-70%, so as to match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__ mechanism. In the process, fix a bug where isinstance() and issubclass(), when given a tuple of classes as second argument, were looking up __instancecheck__ / __subclasscheck__ on the tuple rather than on each type object. Issue #3663: Py_None was decref'd when printing SyntaxErrors. Issue #3651: Fix various memory leaks when using the buffer interface, or when the "s#...
...isinstance() and issubclass() can have their second argument be a tuple whose nested depth is capped at the interpreter's recursion limit. Raises RuntimeError if the limit reached. Made omitted callback and None equivalent for weakref.ref() and weakref.proxy(); the None case wasn't handled correctly in all cases. Fixed problem where PyWeakref_NewRef() and PyWeakref_NewProxy() assumed that initial existing entries in an object's weakref list would not be removed while allocating a new weakref ob...
...isinstance() now allows any object as the first argument and a class, a type or something with a __bases__ tuple attribute for the second argument. The second argument may also be a tuple of a class, type, or something with __bases__, in which case isinstance() will return true if the first argument is an instance of any of the things contained in the second argument tuple. E.g. isinstance(x, (A, B)) returns true if x is an instance of A or B. Extension modules thread.start_new_thread() n...
...IsInstance(), PyObject_IsSubclass() implement isinstance() and issubclass(). Py_BuildValue() now has a "D" conversion to create a Python complex number from a Py_complex C value. Extensions types which support weak references must now set the field allocated for the weak reference machinery to NULL themselves; this is done to avoid the cost of checking each object for having a weakly referencable type in PyObject_INIT(), since most types are not weakly referencable. PyFrame_FastToLocal...
...isinstance() and issubclass() to the recursion limit of the interpreter. Fixes bug #858016 . Optimized dict iterators, creating separate types for each and having them reveal their length. Also optimized the methods: keys(), values(), and items(). Implemented a newcode opcode, LIST_APPEND, that simplifies the generated bytecode for list comprehensions and further improves their performance (about 35%). Implemented rich comparisons for floats, which seems to make comparisons involving NaNs som...
If you didn't find what you need, try your search in the Python language documentation.