What is the difference between ellipsis and pass in python

118 Views Asked by At

Is there any difference between ... or Ellipsis and pass in python? I only found out about it when I was looking through pygame 2.5.0 (installed version). I learned that we use pass to make a function do nothing. This is the file I first found it in:
image.pyi:

from typing import Optional, Sequence, Tuple, Union

from pygame.bufferproxy import BufferProxy
from pygame.surface import Surface
from ._common import FileArg, Literal

_BufferStyle = Union[BufferProxy, bytes, bytearray, memoryview]
_to_string_format = Literal[
    "P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "RGBA_PREMULT", "ARGB_PREMULT"
]
_from_buffer_format = Literal["P", "RGB", "BGR", "BGRA", "RGBX", "RGBA", "ARGB"]
_from_string_format = Literal["P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA"]

def load(filename: FileArg, namehint: str = "") -> Surface: ...
def save(surface: Surface, filename: FileArg, namehint: str = "") -> None: ...
def get_sdl_image_version(linked: bool = True) -> Optional[Tuple[int, int, int]]: ...
def get_extended() -> bool: ...
def tostring(
    surface: Surface, format: _to_string_format, flipped: bool = False
) -> bytes: ...
def fromstring(
    bytes: bytes,
    size: Union[Sequence[int], Tuple[int, int]],
    format: _from_string_format,
    flipped: bool = False,
) -> Surface: ...
# the use of tobytes/frombytes is preferred over tostring/fromstring
def tobytes(
    surface: Surface, format: _to_string_format, flipped: bool = False
) -> bytes: ...
def frombytes(
    bytes: bytes,
    size: Union[Sequence[int], Tuple[int, int]],
    format: _from_string_format,
    flipped: bool = False,
) -> Surface: ...
def frombuffer(
    bytes: _BufferStyle,
    size: Union[Sequence[int], Tuple[int, int]],
    format: _from_buffer_format,
) -> Surface: ...
def load_basic(filename: FileArg) -> Surface: ...
def load_extended(filename: FileArg, namehint: str = "") -> Surface: ...
def save_extended(surface: Surface, filename: FileArg, namehint: str = "") -> None: ...

At first I thought it was the difference between .pyi and .py files, but it appears no different in my terminal:

Python 3.11.6 (main, Oct  2 2023, 13:45:54) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ...
Ellipsis
>>> pass
>>> Ellipsis
Ellipsis
>>> 

What does this actually mean? And should I use it in my scripts? I managed to figure out .pyi files are stubs for when c libraries are there, it helps things like VSCode show the function args.

0

There are 0 best solutions below