Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 3839:22e29b1747e1 legacy-trunk
Changes for slice and ellipses
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 30 Jul 1996 16:49:37 +0000 |
| parents | 516490c8192c |
| children | d55cdf43c240 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Tue Jul 30 16:48:31 1996 +0000 +++ b/Python/bltinmodule.c Tue Jul 30 16:49:37 1996 +0000 @@ -879,6 +879,28 @@ 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 @@ {"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},
