summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-06-11 18:55:38 +0000
committerGeorg Brandl <georg@python.org>2008-06-11 18:55:38 +0000
commitfe83eae28629224dbbc5a4dbc38aa4aa6a59d85a (patch)
tree7cf9b014ffc5038b5819acabf19a806976e7213e /Modules
parent9e91c63655aca442ee50d16acb7edde8dddfbc7e (diff)
downloadcpython-fe83eae28629224dbbc5a4dbc38aa4aa6a59d85a.tar.gz
Add future_builtins.ascii().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/future_builtins.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/future_builtins.c b/Modules/future_builtins.c
index 5baaa6051d..4c840fb161 100644
--- a/Modules/future_builtins.c
+++ b/Modules/future_builtins.c
@@ -45,11 +45,25 @@ PyDoc_STRVAR(oct_doc,
Return the octal representation of an integer or long integer.");
+static PyObject *
+builtin_ascii(PyObject *self, PyObject *v)
+{
+ return PyObject_Repr(v);
+}
+
+PyDoc_STRVAR(ascii_doc,
+"ascii(object) -> string\n\
+\n\
+Return the same as repr(). In Python 3.x, the repr() result will\n\
+contain printable characters unescaped, while the ascii() result\n\
+will have such characters backslash-escaped.");
+
/* List of functions exported by this module */
static PyMethodDef module_functions[] = {
{"hex", builtin_hex, METH_O, hex_doc},
{"oct", builtin_oct, METH_O, oct_doc},
+ {"ascii", builtin_ascii, METH_O, ascii_doc},
{NULL, NULL} /* Sentinel */
};