0

There exists a writer function in python's csv module. I used vscode to find its source code. What I found was just the declaration of the function's name and its arguments and no further code for the function was found.

def writer(
    csvfile: SupportsWrite[str],
    dialect: _DialectLike = ...,
    *,
    delimiter: str = ...,
    quotechar: str | None = ...,
    escapechar: str | None = ...,
    doublequote: bool = ...,
    skipinitialspace: bool = ...,
    lineterminator: str = ...,
    quoting: _QuotingType = ...,
    strict: bool = ...,
) -> _writer: ...

This goes for every other function in this module. Also the extension of the file I found this function in is .pyi


My questions are

  • Where / how is the function defined here
  • What do ... mean here
  • Why the extension for this file is .pyi
Sanmay Kant
  • 149
  • 8
  • `.pyi` files describe the _interface_, you're looking at the TypeShed definition. The actual _implementation_ can be found in https://github.com/python/cpython/blob/main/Lib/csv.py and https://github.com/python/cpython/blob/main/Modules/_csv.c. – jonrsharpe Aug 22 '22 at 10:11
  • As per my knowledge an interface is just the type declaration of members of a class and its methods. I used python's `type` function to find the return type of the `writer` function and it said ``, but there doesn't seem to be any `writer` class in the links that you provided. Can you elaborate on how these interfaces are used and why do we need them in the first place. – Sanmay Kant Aug 22 '22 at 10:36

0 Answers0