I just figured out that PyCharm supports a docstring with code prefixed by >>>
like this:
def foo(x):
"""
Use it like:
>>> foo(42)
"""
print(x)
PyCharm then even applies the usual code highlighting on this.
I tried to find any documentation on this syntax. It doesn't seem to be part of reStructuredText. Also Sphinx does not mention this. Was this introduced in some PEP? Or is this PyCharm specific? But I did not find any PyCharm documentation on this.
(It's hard to use Google search for this. I don't know how to call this. "3-times greater sign"?)
The comments have answered the question. I'm just putting it here for completeness:
It's three fleshes (>>>
).
It's used for doc test.
In PyCharm, when you rightclick it, it allows you to Run Doctest
.
The syntax probably comes from the Python interactive shell.