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 well use co_consts[0].
Seems like I hid the magic constant in some voodoo code. There is an advantage over co_consts[0], though: it balks when there is no docstring. Peter -- http://mail.python.org/mailman/listinfo/python-list