Search code examples
pythonpython-3.xpycharm

Why does print("..."), i.e. three dots in a row, print blank?


I'd like to print three dots in a row (to form an ellipsis), but print() prints blank.

print("one moment...")
one moment...
print("...")

print("..")
..
print("...abc...")
abc...
print("\u2026")
…

What's happening here? Why is "..." parsed in an exceptional way?

I am using ipython in PyCharm.


Solution

  • Update 2024-07-31

    According to the YouTrack issue (archive) this issue has been fixed and is available in builds: 242.6184, 241.16163, 241.17011.12, 242.10180.17.


    Original Post

    Looks like this is a known issue with Pycharm where its interactive console removes the leading three periods from a print statement. Here’s the ticket tracking this issue.


    A possible workaround for now is defining something like:
    def iprint(obj):
        if (s:=str(obj)).startswith("..."):
            print(" "+s)
        else:
            print(s)
    

    which looks like:

    >>> iprint("...ymmv")
     ...ymmv