aboutsummaryrefslogtreecommitdiff
path: root/py/objstrunicode.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-04-04 00:09:23 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-04-04 00:09:48 +0300
commitac2f7a7f6aab135e90dd12d30b51d857628b0a59 (patch)
tree8d4e21696251c3124313073818dd583862c94dfd /py/objstrunicode.c
parent82f37bf0d1080b4f508a6af36088cbe12b50c70b (diff)
objstr: Add .splitlines() method.
splitlines() occurs ~179 times in CPython3 standard library, so was deemed worthy to implement. The method has subtle semantic differences from just .split("\n"). It is also defined as working for any end-of-line combination, but this is currently not implemented - it works only with LF line-endings (which should be OK for text strings on any platforms, but not OK for bytes).
Diffstat (limited to 'py/objstrunicode.c')
-rw-r--r--py/objstrunicode.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 1cf4ed474..4e7f770c3 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -245,6 +245,9 @@ STATIC const mp_map_elem_t struni_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_rindex), (mp_obj_t)&str_rindex_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_join), (mp_obj_t)&str_join_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_split), (mp_obj_t)&str_split_obj },
+ #if MICROPY_PY_BUILTINS_STR_SPLITLINES
+ { MP_OBJ_NEW_QSTR(MP_QSTR_splitlines), (mp_obj_t)&str_splitlines_obj },
+ #endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_rsplit), (mp_obj_t)&str_rsplit_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_startswith), (mp_obj_t)&str_startswith_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_endswith), (mp_obj_t)&str_endswith_obj },