Ejemplo n.º 1
0
 def descr__new__(space, w_slicetype, args_w):
     from pypy.objspace.std.sliceobject import W_SliceObject
     w_start = space.w_None
     w_stop = space.w_None
     w_step = space.w_None
     if len(args_w) == 1:
         w_stop, = args_w
     elif len(args_w) == 2:
         w_start, w_stop = args_w
     elif len(args_w) == 3:
         w_start, w_stop, w_step = args_w
     elif len(args_w) > 3:
         raise oefmt(space.w_TypeError, "slice() takes at most 3 arguments")
     else:
         raise oefmt(space.w_TypeError, "slice() takes at least 1 argument")
     w_obj = space.allocate_instance(W_SliceObject, w_slicetype)
     W_SliceObject.__init__(w_obj, w_start, w_stop, w_step)
     return w_obj
Ejemplo n.º 2
0
 def descr__new__(space, w_slicetype, args_w):
     from pypy.objspace.std.sliceobject import W_SliceObject
     w_start = space.w_None
     w_stop = space.w_None
     w_step = space.w_None
     if len(args_w) == 1:
         w_stop, = args_w
     elif len(args_w) == 2:
         w_start, w_stop = args_w
     elif len(args_w) == 3:
         w_start, w_stop, w_step = args_w
     elif len(args_w) > 3:
         raise oefmt(space.w_TypeError, "slice() takes at most 3 arguments")
     else:
         raise oefmt(space.w_TypeError, "slice() takes at least 1 argument")
     w_obj = space.allocate_instance(W_SliceObject, w_slicetype)
     W_SliceObject.__init__(w_obj, w_start, w_stop, w_step)
     return w_obj
Ejemplo n.º 3
0
 def descr__new__(space, w_slicetype, args_w):
     from pypy.objspace.std.sliceobject import W_SliceObject
     w_start = space.w_None
     w_stop = space.w_None
     w_step = space.w_None
     if len(args_w) == 1:
         w_stop, = args_w
     elif len(args_w) == 2:
         w_start, w_stop = args_w
     elif len(args_w) == 3:
         w_start, w_stop, w_step = args_w
     elif len(args_w) > 3:
         raise oefmt(space.w_TypeError,
                     "cortar() toma por lo máximo 3 argumentos")
     else:
         raise oefmt(space.w_TypeError,
                     "cortar() toma por lo menos 1 argumento")
     w_obj = space.allocate_instance(W_SliceObject, w_slicetype)
     W_SliceObject.__init__(w_obj, w_start, w_stop, w_step)
     return w_obj