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.

Answer from Albert on Stack Overflow
🌐
JetBrains
jetbrains.com › help › pycharm › creating-documentation-comments.html
Create documentation comments | PyCharm Documentation
August 14, 2026 - In the Docstring format dropdown, select reStructuredText. Then type the opening triple double-quotes and press Enter or Space. PyCharm generates a documentation comment stub in reStructuredText format: """ :param self: :param myParam1: :param myParam2: :return: """ You can use markup for text formatting, as well as substitutions, bulleted lists, links, code blocks...
Discussions

Python docstrings and inline code; meaning of the ">>>" syntax - Stack Overflow
I have some experience in Python but only recently came across extensive usage of docstrings. I'm going through the Financial Market Simulator (FMS) source code, and when I open it in PyCharm I see... More on stackoverflow.com
🌐 stackoverflow.com
Plugin that generates documentation using AI
Before you install this plugin, be sure to read the security disclaimers. Your code is uploaded to Mintlify's servers for analysis. That may be fine for some and the disclaimers are saying the right things about protecting that code (encryption, de-identification, right to delete, etc.), but code leaving your machine may be a non-starter for others. Also know that more than just the lines you've highlighted are leaving your machine. It's uploading other code, likely to provide additional context to the AI. More on reddit.com
🌐 r/pycharm
9
59
February 19, 2022
Run Python Fragment in Markdown code block
Shouldn't your question be like if it is possible at all? It's not possible because there would be right click run options as on regular code files. And run configurations don't support MD files with positional hints like "Snippet starting at line 22" or "Snippet #4". More on reddit.com
🌐 r/pycharm
4
1
May 30, 2024
python - How to auto-generate the type of a field in a docstring in PyCharm? - Stack Overflow
Supports Claude Code, Cursor, Codex, Windsurf and more. Explore Stack Overflow for Agents ... Why intent prediction needs more than an... ... 14 How to make PyCharm get type hints from function definition and populate type values in docstrings? More on stackoverflow.com
🌐 stackoverflow.com
🌐
JetBrains
jetbrains.com › help › pycharm › using-docstrings-to-specify-types.html
Specify types with docstrings | PyCharm Documentation
September 1, 2025 - In the list of intention actions that opens, choose Insert a documentation string stub. PyCharm creates a documentation stub, according to the selected docstring format, with the type specification, collected during the debugger session.
🌐
JetBrains
jetbrains.com › help › pycharm › documenting-source-code.html
Document source code | PyCharm Documentation
January 20, 2026 - In the Python files, PyCharm recognizes the documentation comments represented as Python docstrings.
🌐
JetBrains
jetbrains.com › help › pycharm › restructured-text.html
reStructuredText support | PyCharm Documentation
June 25, 2026 - If needed, set alternative colors and effects for markup elements. Click OK to save the changes and close the window. Add any section structure markup and preview the results. Add code fragments by using the .. code-block:: directive.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 18791456147858-docstring-code-block-indentation
docstring code block indentation – IDEs Support (IntelliJ Platform) | JetBrains
May 7, 2024 - I'd like it to display as typed, as a code block or literal block. After searching the docs, I've tried various things including preceding the dict with a line ending with ‘::’, then a blank line, then indenting the dict, such as: def myfunc(args): """I have a docstring with a dict. For example:: mydict = { "key1": val1, "key2": val2, } Yada yada. """ return args · Then the quick documentation shows the following, stripping my leading indentation. Are there PyCharm settings to control this behavior?
🌐
W3Schools
w3schools.io › pycharm-comments
Pycharm How to write a single or block or documentation comments for Python - w3schools
December 31, 2023 - pycharm IDE Editor tutorials & Howto examples How to write a single or block or documentation comments for python
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-37743
reStructuredText Python code block in docstring does not ...
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › pycharm › settings-tools-python-integrated-tools.html
Integrated Tools | PyCharm Documentation
July 19, 2026 - Use this page to configure requirements management file, default test runner, and documentation strings treatment · Package requirements file
Top answer
1 of 3
27

The statements written with >>> in the docstrings are doctests.

It lets you test your code by running examples embedded in the documentation and verifying that they produce the expected results. It parses the help text to find examples, runs them and then compares the output text against the expected value.

In your case, PyCharm has done the extra task of highlighting the python code in the docstrings. It won't affect your normal function execution so you don't need to worry about it.

Example:
Lets say I have a script named doctest_simple_addition in which i have written some doctests for add() function where some test cases gives proper output and some raises an exception. Then i can verify that my function produces the expected results by running those doctests.

doctest_simple_addition.py

def add(a,b):
    """
    >>> add(1, 2)
    3

    >>> add(5, 3)
    8

    >>> add('a', 1)
    Traceback (most recent call last):
        ...
    TypeError: cannot concatenate 'str' and 'int' objects
    """

    return a + b

To run the doctests, use doctest as the main program via the -m option to the interpreter. Usually, no output is produced while the tests are running. You can add the -v option and doctest will then print a detailed log of what it’s trying with a summary at the end.

Doctest looks for lines beginning with the interpreter prompt, >>>, to find the beginning of a test case. The test case is ended by a blank line, or by the next interpreter prompt.

$ python -m doctest -v doctest_simple_addition.py 

Trying:
    add(1, 2)
Expecting:
    3
ok
Trying:
    add(5, 3)
Expecting:
    8
ok
Trying:
    add('a', 1)
Expecting:
    Traceback (most recent call last):
        ...
    TypeError: cannot concatenate 'str' and 'int' objects
ok
1 items had no tests:
    doctest_simple_addition
1 items passed all tests:
   3 tests in doctest_simple_addition.add
3 tests in 2 items.
3 passed and 0 failed.
Test passed.

Note: When doctest sees a traceback header line (either Traceback (most recent call last): or Traceback (innermost last):, depending on the version of Python you are running), it skips ahead to find the exception type and message, ignoring the intervening lines entirely.
This is done because paths in a traceback depend on the location where a module is installed on the filesystem on a given system and it would be impossible to write portable tests as the path would change from system to system.

2 of 3
5

Your intuition is correct, they are to be executed. But don't worry, they are doctest strings. They won't interfere with the normal execution of a module, so everything is fine. PyCharm is just being helpful by recognizing them.

🌐
JetBrains
jetbrains.com › help › pycharm › type-syntax-for-docstrings.html
Legacy type syntax for docstrings | PyCharm Documentation
March 18, 2026 - :rtype: list[int] for my_iter # return type: 'a' is of type int, see the following code: def my_iter(): for i in range(10): yield i for a in my_iter(): print a · Consider adding information about the expected parameter type. This information is specified using docstrings.
🌐
Reddit
reddit.com › r/pycharm › plugin that generates documentation using ai
r/pycharm on Reddit: Plugin that generates documentation using AI
February 19, 2022 - For me its most useful feature is that it tells you what the robot thinks you were trying to do with a code block. That might be very different than what you intended to do. That's powerful.
🌐
Reddit
reddit.com › r/pycharm › run python fragment in markdown code block
r/pycharm on Reddit: Run Python Fragment in Markdown code block
May 30, 2024 -

Just for example say I have a code block in a markdown file like this

import os
print(os.getcwd())

I get python completions of course, but how can I make a run/debug configuration to run the code block in a terminal or the python console?

Alternatively or as a bonus, how would I run the code after opening with the "Edit Python fragment" code action?

🌐
JetBrains
jetbrains.com › pycharm › guide › tutorials › sphinx_sites › documentation
Documenting Code - JetBrains Guide
February 17, 2023 - Our my_demo.MyClass has a minimal docstring and does not use type hints for parameters and return values.
🌐
Medium
medium.com › jit-team › documenting-python-code-with-docstrings-b999ee164ff2
Documenting Python code with docstrings | by Adam Czapski | Jit Team | Medium
September 14, 2022 - One of the most important things to document in Python code are docstrings. Docstrings are strings that are used to document a code block, and they are typically placed at the beginning of a code block.
🌐
JetBrains
jetbrains.com › help › pycharm › viewing-reference-information.html
Code reference information | PyCharm Documentation
August 18, 2026 - You can get quick information for any symbol right from the editor with the Quick Documentation feature. It shows you code documentation in a popup as you hover over code elements. PyCharm recognizes inline documentation created in accordance with PEP-257.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 5977082118930-Pycharm-stopped-auto-docstring
Pycharm stopped auto docstring. – IDEs Support (IntelliJ Platform) | JetBrains
June 8, 2022 - When I use to write a function, if I start a doc string with three double quotes just below a function signature, pycharm would partially fill out all the documentation like params and return values. Right now, it doesn't happen anymore. I figure it's a project setting that I must have accidentally changed. How do I turn it back on? ... Thank for the follow up. Here's what I have for docstring under Python Integrated Tools: Docstring format: Plain [x] Analyze code in docstring.
🌐
JetBrains
jetbrains.com › help › pycharm › enabling-creation-of-documentation-comments.html
Manage documentation comments | PyCharm Documentation
January 21, 2026 - To restrict creating documentation comments, press Ctrl+Alt+S to open settings and select Python | Tools | Integrated Tools. In the Docstrings area, select Plain from the Docstring format list.
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-37743 › reStructuredText-Python-code-block-in-docstring-does-not-render
reStructuredText Python code block in docstring does not render
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.