diff options
author | Eric Smith <eric@trueblade.com> | 2008-02-22 16:30:22 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-02-22 16:30:22 (GMT) |
commit | 3cd8194b9c8a8380a95db9d1b9ecd048a960316b (patch) | |
tree | 6ee381b2747f26d09219b451ae3bcd402f3b040e /Python/bltinmodule.c | |
parent | 1699db145fd482704173b2da072981ea52c47141 (diff) | |
download | cpython-3cd8194b9c8a8380a95db9d1b9ecd048a960316b.zip cpython-3cd8194b9c8a8380a95db9d1b9ecd048a960316b.tar.gz cpython-3cd8194b9c8a8380a95db9d1b9ecd048a960316b.tar.bz2 |
Added bin() builtin. I'm going to check in the tests in a seperate checkin, because the builtin doesn't need to be ported to py3k, but the tests are missing in py3k and need to be merged there.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a9d68ca..71beeba 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -209,6 +209,18 @@ Deprecated since release 2.3. Instead, use the extended call syntax:\n\ static PyObject * +builtin_bin(PyObject *self, PyObject *v) +{ + return PyNumber_ToBase(v, 2); +} + +PyDoc_STRVAR(bin_doc, +"bin(number) -> string\n\ +\n\ +Return the binary representation of an integer or long integer."); + + +static PyObject * builtin_callable(PyObject *self, PyObject *v) { if (Py_Py3kWarningFlag && @@ -2366,6 +2378,7 @@ static PyMethodDef builtin_methods[] = { {"all", builtin_all, METH_O, all_doc}, {"any", builtin_any, METH_O, any_doc}, {"apply", builtin_apply, METH_VARARGS, apply_doc}, + {"bin", builtin_bin, METH_O, bin_doc}, {"callable", builtin_callable, METH_O, callable_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, |