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

Question:

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.

Asked By: P2000

||

Answers:

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
Answered By: 0x263A
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.