types and objects user-defined functions user-defined functions are callable objects created at the module level by using the def statement or with the lambda operator here' an exampledef foo( , )return bar lambda ,yx user-defined function has the following attributesattribute(sdescription _doc_ _name_ _dict_ _code_ _defaults_ _globals_ _closure_ documentation string function name dictionary containing function attributes byte-compiled code tuple containing the default arguments dictionary defining the global namespace tuple containing data related to nested scopes in older versions of python many of the preceding attributes had names such as func_codefunc_defaultsand so on the attribute names listed are compatible with python and python methods methods are functions that are defined inside class definition there are three common types of methods--instance methodsclass methodsand static methodsclass foo(object)def instance_method(self,arg)statements @classmethod def class_method(cls,arg)statements @staticmethod def static_method(arg)statements an instance method is method that operates on an instance belonging to given class the instance is passed to the method as the first argumentwhich is called self by convention class method operates on the class itself as an object the class object is passed to class method in the first argumentcls static method is just function that happens to be packaged inside class it does not receive an instance or class object as first argument both instance and class methods are represented by special object of type types methodtype howeverunderstanding this special type requires careful understanding of how object attribute lookup works the process of looking something up on an object is always separate operation from that of making function call when you invoke methodboth operations occurbut as distinct steps this example illustrates the process of invoking instance_method(argon an instance of foo in the preceding listingf foo(meth instance_method meth( create an instance lookup the method and notice the lack of (now call the method lib fl ff