title: How does str.startswith really work?
body: <p>I've been playing for a bit with <code>startswith()</code> and I've discovered something interesting:</p>
  
  <pre><code>&gt;&gt;&gt; tup = ('1', '2', '3')
  &gt;&gt;&gt; lis = ['1', '2', '3', '4']
  &gt;&gt;&gt; '1'.startswith(tup)
  True
  &gt;&gt;&gt; '1'.startswith(lis)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: startswith first arg must be str or a tuple of str, not list
  </code></pre>
  
  <p>Now, the error is obvious and casting the list into a tuple will work just fine as it did in the first place:</p>
  
  <pre><code>&gt;&gt;&gt; '1'.startswith(tuple(lis))
  True
  </code></pre>
  
  <p>Now, my question is: why the <em>first argument must be str or a tuple of str prefixes, but not a list</em> of str prefixes?</p>
  
  <p>AFAIK, the Python code for <code>startswith()</code> might look like this:</p>
  
  <pre><code>def startswith(src, prefix):
      return src[:len(prefix)] == prefix
  </code></pre>
  
  <p>But that just confuses me more, because even with it in mind, it still shouldn't make any difference whether is a list or tuple. What am I missing ?</p>