importsysinfo=sys.version_infoimportunittest2try:callable=callableexceptNameError:defcallable(obj):returnhasattr(obj,'__call__')with_available=sys.version_info[:2]>=(2,5)defis_instance(obj,klass):"""Version of is_instance that doesn't access __class__"""returnissubclass(type(obj),klass)classSomeClass(object):class_attribute=Nonedefwibble(self):passclassX(object):passtry:next=nextexceptNameError:defnext(obj):returnobj.next()