Gabriel Genellina 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.
The lazy coder's approach:
>>> compiler.parse("""
... 'the docstring'
... print 42
... """).doc
'the
Fredrik Lundh wrote:
> 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
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].
--
http:
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 hav
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
Gabriel Genellina wrote:
> 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 execut
Gabriel Genellina 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 on
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 b