| 
 
 
 
 all, any, callable, hasattr, isinstance, issubclass
 
Draft for Information Only ContentPython Built-in Boolean Functions
 all()Parameters
 Remarks
 
 any()Parameters
 Remarks
 
 callable()Parameters
 Remarks
 
 hasattr()Parameters
 Remarks
 
 isinstance()Parameters
 Remarks
 
 issubclass()Parameters
 Remarks
 Source and Reference
 
Python Built-in Boolean Functions
The Python interpreter has some built-in boolean functions.
     all()
all(iterable)Parametersall()to return aTrueif all elements of the specifiediterableare true.iterableto specify the iterable to be returned fromRemarksIf all elements of the object are true or the object is empty, then all()returnsTrueEquivalent to:
            def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True
 any()
any(iterable)Parametersany()to return aTrueif any elements of the specified object are true and the object is not empty.RemarksIf the iterableis empty, return False.If any element of the iterable is trueEquivalent to:
            def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
 callable()
callable(object)Parameterscallable()to returnTrueif the specified object appears callable.objectto specify the object to be returned fromRemarksIf objectappears callable, returnTrueIs objectappears not callable, returnFalseA callablethat returnsTrue, is still possible that a call fails, but if acallablethat returnsFalsewill never succeed to call theobject.Classes are callable (calling a class returns a new instance), and instances are callable if their class has a __call__()method.
 hasattr()
hasattr(object, name)Parametershasattr()to returnTrueif the specifiednameis one attribute of the specifiedobject.RemarksThis is implemented by calling getattr(object, name) and seeing whether it raises an AttributeError or not.
 isinstance()
isinstance(object, classinfo)Parametersisinstance()to returnTrueif the specifiedobjectis an instance of the givenclassinfo, or of a direct, indirect, or virtual subclass thereof.objectto specify the object to be returned fromclassinfoto specify the type of object to be refered toRemarksif objectis an instance of theclassinfo, or of a direct, indirect, or virtual ssubclass thereof,isinstance()returnsTrueIf objectin not an object of the given type,isinstance()returnsFalseIf classinfois a tuple of type objects or recursively, other such tuples, returnTrueifobjectis an instance of any of the types.if classinfois not a type or tuple of types and such tuples, aTypeErrorexception is raised.
 issubclass()
issubclass(class, classinfo)Parametersissubclass()to returnTrueif the specifiedclassis a direct, indirect, or virtual subclass ofclassinfoclassto specify the class to be returned fromclassinfoto specify the type of object to be refered toRemarksA class is considered a subclass of itself.classinfomay be a tuple of class objects, in which case every entry inclassinfowill be checked.classinfoof other case, aTypeErrorexception is raised.
 Source and Reference©sideway
 
 ID: 200602502 Last Updated: 6/25/2020 Revision: 0 |  |