several other top-level functions rely on calling specially named methods for examplethe standard way to determine the size of container type is by calling the top-level len function note well that the calling syntaxlen(foo)is not the traditional method-calling syntax with the dot operator howeverin the case of user-defined classthe top-level len function relies on call to specially named len method of that class that isthe call len(foois evaluated through method callfoo len when developing data structureswe will routinely define the len method to return measure of the size of the structure implied methods as general ruleif particular special method is not implemented in user-defined classthe standard syntax that relies upon that method will raise an exception for exampleevaluating the expressiona bfor instances of user-defined class without add or radd will raise an error howeverthere are some operators that have default definitions provided by pythonin the absence of special methodsand there are some operators whose definitions are derived from others for examplethe bool methodwhich supports the syntax if foo:has default semantics so that every object other than none is evaluated as true howeverfor container typesthe len method is typically defined to return the size of the container if such method existsthen the evaluation of bool(foois interpreted by default to be true for instances with nonzero lengthand false for instances with zero lengthallowing syntax such as if waitlistto be used to test whether there are one or more entries in the waitlist in section we will discuss python' mechanism for providing iterators for collections via the special methoditer with that saidif container class provides implementations for both len and getitem default iteration is provided automatically (using means we describe in section furthermoreonce an iterator is defineddefault functionality of contains is provided in section we drew attention to the distinction between expression is and expression =bwith the former evaluating whether identifiers and are aliases for the same objectand the latter testing notion of whether the two identifiers reference equivalent values the notion of "equivalencedepends upon the context of the classand semantics is defined with the eq method howeverif no implementation is given for eq the syntax = is legal with semantics of is bthat isan instance is equivalent to itself and no others we should caution that some natural implications are not automatically provided by python for examplethe eq method supports syntax =bbut providing that method does not affect the evaluation of syntax ! (the ne method should be providedtypically returning not ( =bas result similarlyproviding lt method supports syntax abut providing both lt and eq does not imply semantics for <