diff options
author | Guido van Rossum <guido@python.org> | 1996-07-30 16:49:37 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-30 16:49:37 (GMT) |
commit | 8861b74445560c078d11ff6800a3ce20a869ea93 (patch) | |
tree | 67426f7e9173e2c4a0f0040f1f97ed7c3270dbc2 /Python/bltinmodule.c | |
parent | 3ecebf17324b138a9d10ad429c0ad55ab5de1682 (diff) | |
download | cpython-8861b74445560c078d11ff6800a3ce20a869ea93.zip cpython-8861b74445560c078d11ff6800a3ce20a869ea93.tar.gz cpython-8861b74445560c078d11ff6800a3ce20a869ea93.tar.bz2 |
Changes for slice and ellipses
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3a3fe56..00e02de 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -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}, |