__doc__ in compiled script

Fredrik Lundh fredrik at pythonware.com
Fri Nov 3 02:45:21 EST 2006


Gabriel Genellina wrote:

>> >>> co.co_consts[list(co.co_names).index("__doc__")]
>> 'This is a docstring'
> 
> Good! I'll buy this one :) thanks!

however, there's no 1:1 mapping between names and constants; if you want 
code that works by accident, you might as well use co_consts[0].

</F>




More information about the Python-list mailing list