How does str.startswith really work?

后端 未结 3 1552
广开言路
广开言路 2020-12-06 09:30

I\'ve been playing for a bit with startswith() and I\'ve discovered something interesting:

>>> tup = (\'1\', \'2\', \'3\')
>>>         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 10:06

    On a similar note, here is an excerpt from a talk by core developer, Raymond Hettinger discussing API design choices regarding certain string methods, including recent changes to the str.startswith signature. While he briefly mentions this fact that str.startswith accepts a string or tuple of strings and does not expound, the talk is informative on the decisions and pain points both core developers and contributors have dealt with leading up to the present API.

提交回复
热议问题