sharing data across Examples docstrings

Sebastian Luque spluque at gmail.com
Tue Jan 11 17:09:57 EST 2022


Hello,

I am searching for a mechanism for sharing data across Examples sections
in docstrings within a class.  For instance:

class Foo:

    def foo(self):
        """Method foo title

        The example generating data below may be much more laborious.

        Examples
        --------
        >>> x = list("abc")  # may be very long and tedious to generate

        """
        pass

    def bar(self):
        """Method bar title

        Examples
        --------
        >>> # do something else with x from foo Example

        """
        pass


Thanks,
-- 
Seb


More information about the Python-list mailing list