Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, <code>__code__</code> and <code>func_code</code> are references to the compiled bytecode -- you can disassemble them (see <code>dis.dis</code>) but not get back to the Python source code.</p> <p>Alas, the source code is simply gone, not remembered anywhere...:</p> <pre><code>&gt;&gt;&gt; import inspect &gt;&gt;&gt; def f(): ... print 'ciao' ... &gt;&gt;&gt; inspect.getsource(f) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 694, in getsource lines, lnum = getsourcelines(object) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 683, in getsourcelines lines, lnum = findsource(object) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 531, in findsource raise IOError('could not get source code') IOError: could not get source code &gt;&gt;&gt; </code></pre> <p>If <code>inspect</code> can't get to it, that's a pretty indicative sign.</p> <p>If you were on a platform using GNU <code>readline</code> (basically, any <strong>except</strong> Windows), you might exploit the fact that <code>readline</code> itself <strong>does</strong> remember some "history" and can write it out to a file...:</p> <pre><code>&gt;&gt;&gt; readline.write_history_file('/tmp/hist.txt') </code></pre> <p>and then read that history file -- however, I know of no way to do this in Windows.</p> <p>You may want to use some IDE with better memory capabilities, rather than the "raw" command interpreter, especially on a platform such as Windows.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload