__doc__ in compiled script

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Nov 2 15:38:35 EST 2006


Hello

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).

--- begin test.py ---
body = """
"This is a docstring"

x=0
some(code).toBeExecuted("later")
"""

co = compile(body,'<string>','exec')
print co.__doc__

# what can I use for "something" below: ?
assert something(co)=="This is a docstring"
--- end test.py ---


-- 
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