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

Time:06-01

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...

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

(This is in ipython in PyCharm. I'm happy to know it might just be a bug rather than a special language feature I wasn't aware of)

CodePudding user response:

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 the issue.

CodePudding user response:

EDIT:
It may be an error with your IDE, try restarting it. Otherwise you gotta see an opticist.
I have ran test cases for both Python 2.x and 3.x and found the following output.

Python 3.x

>>> print("...")
...

>>> print(...)
Ellipsis

Python 2.x

>>> print("...")
...

>>> print(...)
Invalid Syntax Error

OLD:

Python Ellipsis (...) is taken as a placeholder

It is used as a placeholder; when you intend to fill in a Python function later on, but still want to have a valid syntax. It appears as blank as it returns None.

# style1
def foo():
    pass
# style2
def foo():
    ...
# both the styles are same

pass doesn't passes in value whereas ... passes in None.

  • Related