title: Why can't I use inspect.getsource() to view the source for list?
body: <p>I tried to retrieve the source code for the <code>list</code> class using the <a href="https://docs.python.org/library/inspect.html" rel="noreferrer"><code>inspect</code></a> module, without success:</p>
  
  <pre><code>&gt;&gt;&gt; import inspect
  &gt;&gt;&gt; inspect.getsource(list)
  Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python2.7/inspect.py", line 701, in getsource
      lines, lnum = getsourcelines(object)
  File "/usr/lib/python2.7/inspect.py", line 690, in getsourcelines
      lines, lnum = findsource(object)
  File "/usr/lib/python2.7/inspect.py", line 526, in findsource
      file = getfile(object)
  File "/usr/lib/python2.7/inspect.py", line 408, in getfile
      raise TypeError('{!r} is a built-in class'.format(object))
  TypeError: &lt;module '__builtin__' (built-in)&gt; is a built-in class
  </code></pre>
  
  <p>I don't understand why this didn't work - <a href="https://docs.python.org/library/inspect.html#inspect.getsource" rel="noreferrer">the documentation for <code>inspect.getsource()</code></a> says that </p>
  
  <blockquote>
    <p>An IOError is raised if the source code cannot be retrieved.</p>
  </blockquote>
  
  <p>... but doesn't explain why that might happen (and in any case I got a <code>TypeError</code>, not an <code>IOError</code>).</p>
  
  <p>Is there some other way I can programmatically retrieve the source for an object in cases like this? If not, how can I find the source for myself?</p>