In article <[EMAIL PROTECTED]>, gtb <[EMAIL PROTECTED]> wrote: >On Mar 21, 3:35 pm, Peter Otten <[EMAIL PROTECTED]> wrote: . . . >> >>> import sys >> >>> def docstring(): >> >> ... return sys._getframe(1).f_code.co_consts[0] >> ...>>> def foo(): >> >> ... print "My docstring is %r" % docstring() >> ...>>> def bar(): >> >> ... "bar's docstring" >> ... print "My docstring is %r" % docstring() >> ...>>> foo() >> >> My docstring is None>>> bar() >> >> My docstring is "bar's docstring" >> >> No idea how brittle that might be, though. >> >> Peter > >Thanks. > >Pardon my ignorance, but brittle? >
Peter is trying to communicate that some aspects of Python are quite conservative, well-documented, and unlikely to change across versions or implementations. The syntax of, let's say, "def", is an example of such an aspect. Peter has no particular evidence about the guarantees of the sys._getframe(1).f_code.co_consts[0] resolution; for all he or I know, the core Python maintainers might change in an upcoming release the implementation of co_consts. That's what I believe he intends you understand by "brittle". -- http://mail.python.org/mailman/listinfo/python-list