How does str.startswith really work?
There is technically no reason to accept other sequence types, no. The source code roughly does this: if isinstance(prefix, tuple): for substring in prefix: if not isinstance(substring, str): raise TypeError(…) return tailmatch(…) elif not isinstance(prefix, str): raise TypeError(…) return tailmatch(…) (where tailmatch(…) does the actual matching work). So yes, any iterable would do for that … Read more