__doc__ in compiled script

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Nov 2 19:57:03 EST 2006


At Thursday 2/11/2006 17:54, Peter Otten wrote:

> > I have a script starting with a docstring. After compiling it with
> > compile(), is there any way I could get the docstring? __doc__ on the
> > code object doesn't work.
> > I can't use __import__ because the script has top-level statements
> > that have to be executed only once (it's not supposed to be used as a
> > module).
>
> >>> co.co_consts[list(co.co_names).index("__doc__")]
>'This is a docstring'

Good! I'll buy this one :) thanks!


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list