P
P
PesyCorm2021-10-20 12:42:24
Python
PesyCorm, 2021-10-20 12:42:24

What the ... instead of a function body?

Hey!
Sometimes I look into the source code and find nothing for myself, because instead of the body of the function after the colon there are ...

def connect_ex(self, address: Union[_Address, bytes]) -> int: ...
def detach(self) -> int: ...
def dup(self) -> socket: ...

What it is? How can I see the source of a function?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-10-20
@PesyCorm

You could at least google what kind of file you are trying to look there:

.pyi files are stubs, their purpose and format is described in PEP 484. These files are not used by the interpreter at all, their purpose is to provide code typing information. For example, you have a third-party module without typing, which is not yours, you cannot edit it, but you would like to prescribe types:
# fizz.py

def greet(who):
    return f'Hello {who}'

The solution is found with the help of a stub: you create a fizz.pyi file that contains a typed greet signature without implementation:
# fizz.pyi

def greet(who: str) -> str:
    ...

Code implementation is NOT PROVIDED in these files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question