当前位置: 首页>>代码示例>>Python>>正文


Python StdTypeDef.acceptable_as_base_class方法代码示例

本文整理汇总了Python中pypy.objspace.std.stdtypedef.StdTypeDef.acceptable_as_base_class方法的典型用法代码示例。如果您正苦于以下问题:Python StdTypeDef.acceptable_as_base_class方法的具体用法?Python StdTypeDef.acceptable_as_base_class怎么用?Python StdTypeDef.acceptable_as_base_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.objspace.std.stdtypedef.StdTypeDef的用法示例。


在下文中一共展示了StdTypeDef.acceptable_as_base_class方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WrappedDefault

# 需要导入模块: from pypy.objspace.std.stdtypedef import StdTypeDef [as 别名]
# 或者: from pypy.objspace.std.stdtypedef.StdTypeDef import acceptable_as_base_class [as 别名]
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.inttype import int_typedef

@unwrap_spec(w_obj = WrappedDefault(False))
def descr__new__(space, w_booltype, w_obj):
    space.w_bool.check_user_subclass(w_booltype)
    if space.is_true(w_obj):
        return space.w_True
    else:
        return space.w_False

# ____________________________________________________________

bool_typedef = StdTypeDef("bool", int_typedef,
    __doc__ = '''bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.''',
    __new__ = interp2app(descr__new__),
    )
bool_typedef.acceptable_as_base_class = False
开发者ID:charred,项目名称:pypy,代码行数:25,代码来源:booltype.py

示例2: isinstance

# 需要导入模块: from pypy.objspace.std.stdtypedef import StdTypeDef [as 别名]
# 或者: from pypy.objspace.std.stdtypedef.StdTypeDef import acceptable_as_base_class [as 别名]
    """
    from pypy.objspace.std.iterobject import W_ReverseSeqIterObject

    assert isinstance(w_self, W_ReverseSeqIterObject)
    from pypy.interpreter.mixedmodule import MixedModule

    w_mod = space.getbuiltinmodule("_pickle_support")
    mod = space.interp_w(MixedModule, w_mod)
    new_inst = mod.get("reverseseqiter_new")
    tup = [w_self.w_seq, space.wrap(w_self.index)]
    return space.newtuple([new_inst, space.newtuple(tup)])


# ____________________________________________________________
iter_typedef = StdTypeDef(
    "sequenceiterator",
    __doc__="""iter(collection) -> iterator
iter(callable, sentinel) -> iterator

Get an iterator from an object.  In the first form, the argument must
supply its own iterator, or be a sequence.
In the second form, the callable is called until it returns the sentinel.""",
    __reduce__=gateway.interp2app(descr_seqiter__reduce__),
)
iter_typedef.acceptable_as_base_class = False

reverse_iter_typedef = StdTypeDef(
    "reversesequenceiterator", __reduce__=gateway.interp2app(descr_reverseseqiter__reduce__)
)
reverse_iter_typedef.acceptable_as_base_class = False
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:32,代码来源:itertype.py


注:本文中的pypy.objspace.std.stdtypedef.StdTypeDef.acceptable_as_base_class方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。