[Python-checkins] r60962 - python/trunk/Python/bltinmodule.c

eric.smith python-checkins at python.org
Fri Feb 22 17:30:22 CET 2008


Author: eric.smith
Date: Fri Feb 22 17:30:22 2008
New Revision: 60962

Modified:
   python/trunk/Python/bltinmodule.c
Log:
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.

Modified: python/trunk/Python/bltinmodule.c
==============================================================================
--- python/trunk/Python/bltinmodule.c	(original)
+++ python/trunk/Python/bltinmodule.c	Fri Feb 22 17:30:22 2008
@@ -209,6 +209,18 @@
 
 
 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 @@
  	{"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},


More information about the Python-checkins mailing list