From eb45d97898abd9aae93d0c953634cabb5ea327e3 Mon Sep 17 00:00:00 2001 From: Glenn Moloney Date: Tue, 25 Feb 2025 14:36:29 +1100 Subject: py/objstr: Support tuples and start/end args in startswith and endswith. This change allows tuples to be passed as the prefix/suffix argument to the `str.startswith()` and `str.endswith()` methods. The methods will return `True` if the string starts/ends with any of the prefixes/suffixes in the tuple. Also adds full support for the `start` and `end` arguments to both methods for compatibility with CPython. Tests have been updated for the new behaviour. Signed-off-by: Glenn Moloney --- tests/basics/string_endswith_upy.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 tests/basics/string_endswith_upy.py (limited to 'tests/basics/string_endswith_upy.py') diff --git a/tests/basics/string_endswith_upy.py b/tests/basics/string_endswith_upy.py deleted file mode 100644 index 06a4e71d2..000000000 --- a/tests/basics/string_endswith_upy.py +++ /dev/null @@ -1,6 +0,0 @@ -# MicroPython doesn't support tuple argument - -try: - "foobar".endswith(("bar", "sth")) -except TypeError: - print("TypeError") -- cgit v1.2.3