Python types 模块,NotImplementedType() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用types.NotImplementedType()

项目:tichu-tournament    作者:aragos    | 项目源码 | 文件源码
def isNonPrimitiveInstance(x):
        return isinstance(x,types.InstanceType) or not isinstance(x,(float,int,long,type,tuple,list,dict,bool,unicode,str,buffer,complex,slice,types.NoneType,
                    types.FunctionType,types.LambdaType,types.CodeType,types.GeneratorType,
                    types.ClassType,types.UnboundMethodType,types.MethodType,types.BuiltinFunctionType,
                    types.BuiltinMethodType,types.ModuleType,types.FileType,types.XRangeType,
                    types.TracebackType,types.FrameType,types.EllipsisType,types.DictProxyType,
                    types.NotImplementedType,types.GetSetDescriptorType,types.MemberDescriptorType
                    ))
项目:neurotools    作者:michaelerule    | 项目源码 | 文件源码
def is_probably_safe(x):
    '''
    Objects are probably "safe" (unlikly to change) if they are
    -- immutable
    -- functions
    -- modules
    Obviously, the latter two may change, but in practice it is likely
    ok. Still, risky!
    '''
    if is_immutable(x): return True
    if sys.version_info > (3,):
        probably_fine = (\
            types.LambdaType,
            types.BuiltinMethodType,
            types.BuiltinFunctionType,
            types.FunctionType,
            types.ModuleType,
            types.MethodType)
    else:
        probably_fine = (\
            types.LambdaType,
            types.InstanceType,
            types.NoneType,
            types.NotImplementedType,
            types.TypeType,
            types.UnicodeType,
            types.ComplexType,
            types.ClassType,
            types.BuiltinMethodType,
            types.BuiltinFunctionType,
            types.FunctionType,
            types.ModuleType,
            types.MethodType)

    if type(x) in probably_fine: return True
    if hasattr(x,'__call__'): return True
    return False