docstring test

docstring test#

Here is where I got this from:

https://stackoverflow.com/questions/8822701/how-to-print-docstring-of-python-function-from-inside-the-function-itself

def foo(arg1=10,arg2=100):
    """Return the square of a."""
    a = arg1 + arg2
    return a
%pdef foo
 foo(arg1=10, arg2=100)
 
import inspect
lines = inspect.getsource(foo)
print(lines)
def foo(arg1=Integer(10),arg2=Integer(100)):
    """Return the square of a."""
    a = arg1 + arg2
    return a
import inspect
from IPython.display import display, Markdown, Latex, display_markdown
def func2():
    r"""
    Return the point `(x^5,y)`.

    INPUT:

    - ``z`` -- integer (default: `1`); the description of the
      argument ``x`` goes here. If it contains multiple lines, all
      the lines after the first need to begin at the same indentation
      as the backtick.

    - ``w`` -- integer (default: `2`); the description of the
      argument ``y``
    """
    x=1
    return x
display(Markdown(inspect.getdoc(func2)))

Return the point (x^5,y).

INPUT:

  • z – integer (default: 1); the description of the argument x goes here. If it contains multiple lines, all the lines after the first need to begin at the same indentation as the backtick.

  • w – integer (default: 2); the description of the argument y

help(func2)
Help on function func2 in module __main__:

func2()
    Return the point `(x^5,y)`.

    INPUT:

    - ``z`` -- integer (default: `1`); the description of the
      argument ``x`` goes here. If it contains multiple lines, all
      the lines after the first need to begin at the same indentation
      as the backtick.

    - ``w`` -- integer (default: `2`); the description of the
      argument ``y``

The following %pdoc magic does not work in jupyter-book, even thought it works in .ipnb

%pdoc func2