__doc__ in compiled script

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Nov 2 22:16:35 CET 2006

At Thursday 2/11/2006 17:59, Fredrik Lundh 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).
>(or you can just look in co.co_consts[0] and hope for the best)

I'll use co.co_consts[0] and check it's a string - it may fail when 
there is no docstring and the first const referenced is a string, but 
it's good enough for me. 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