often you may not care about the type of an object but rather only whether it has certain methods or behavior for exampleyou can verify that an object is iterable if it implemented the iterator protocol for many objectsthis means it has __iter__ "magic method"though an alternative and better way to check is to try using the iter functiondef isiterable(obj)tryiter(objreturn true except typeerrornot iterable return false this function would return true for strings as well as most python collection typesin [ ]isiterable(' string'out[ ]true in [ ]isiterable([ ]out[ ]true in [ ]isiterable( out[ ]false place where use this functionality all the time is to write functions that can accept multiple kinds of input common case is writing function that can accept any kind of sequence (listtuplendarrayor even an iterator you can first check if the object is list (or numpy arrayandif it is notconvert it to be oneif not isinstance(xlistand isiterable( ) list(ximports in python module is simply py file containing function and variable definitions along with such things imported from other py files suppose that we had the following modulesome_module py pi def ( )return def (ab)return if we wanted to access the variables and functions defined in some_module pyfrom another file in the same directory we could doimport some_module result some_module ( pi some_module pi or equivalentlyfrom some_module import fgpi result ( pi appendixpython language essentials www it-ebooks info