Changes for slice and ellipses

This commit is contained in:
Guido van Rossum 1996-07-30 16:49:37 +00:00
parent 3ecebf1732
commit 8861b74445
6 changed files with 389 additions and 215 deletions

View file

@ -879,6 +879,28 @@ builtin_list(self, args)
return NULL;
}
static PyObject *
builtin_slice(self, args)
PyObject *self;
PyObject *args;
{
PyObject *start, *stop, *step;
start = stop = step = NULL;
if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step))
return NULL;
/*This swapping of stop and start is to maintain compatibility with
the range builtin.*/
if (stop == NULL) {
stop = start;
start = NULL;
}
return PySlice_New(start, stop, step);
}
static object *
builtin_locals(self, args)
object *self;
@ -1514,6 +1536,7 @@ static struct methodlist builtin_methods[] = {
{"repr", builtin_repr, 1},
{"round", builtin_round, 1},
{"setattr", builtin_setattr, 1},
{"slice", builtin_slice, 1},
{"str", builtin_str, 1},
{"tuple", builtin_tuple, 1},
{"type", builtin_type, 1},