ChatGPT解决这个技术问题 Extra ChatGPT

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.

Another thing that pops up sometimes - not this time it seems but still potentially worth mentioning - is charset weirdness + "smart" ellipses (U+2026). This is doubly fun when combined with anything that strips out high characters. A bare turns into … in CP-1252 - or nothing at all in 7-bit ASCII. "…".encode('utf8').decode('ascii', errors='ignore') == ""
This is neither an answer nor a solution, but if you really want the ellipsis, you can generate a real one from the keyboard. On Mac it’s opt-;, while on Windows it’s alt-0133 where the numbers are on the numeric keypad.
I am using PyCharm on my Mac, and tried both print('… watch this space …') and print('... watch this space ...'). Both printed perfectly. Using 2021.3.1 (Community Edition).
@Manngo yes that works, but have you tried with ipython in pycharm?

0
0x263A

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.

def iprint(obj):
    if (s:=str(obj)).startswith("..."):
        print('\n'+s)
    else:
        print(s)

which looks like:

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

...ymmv

@P2000 first reported in 2018! Seems like something they would’ve fixed by now maybe a temporary solution would be to write a custom print function that just checks str(x).startswith(“…”) and prepends a newline or something if true
"Seems like something they would’ve fixed by now" - you'd think so, wouldn't you? I would. But I keep encountering very old unfixed bugs in Pycharm, for example: it still doesn't recognise that the result of functools.partialmethod() is callable, and it's been six years
@AaronF I don't understand either. It's a super IDE, and I'd be very happy if they just spent <20% on new features but >80% on fixes for the next 12mo.
Maybe they overrode it with some ellipsis interpretation.