In (some) python libraries, when i look up the code, i see a bunch of functions or class methods which are written like this:
def funcName():
pass
I just want to know how those functions DO stuff even though they only have pass which means that the function should do nothing.
For user-defined functions, pass means doing nothing, but for some library functions (including third-party libraries), they usually mean that their logic is not written in pure Python code, such as NumPy and Python standard library, in order to pursue efficient operation, most functions are written in C language, and provides the corresponding Python interface.
More detailed answer
Functions in python syntactically can't be empty. That's why you need to populate them, usually with pass
Sometimes, functions are declared, but purposely left empty. Then, they can be used in the default implementations, but possibly overridden by classes extending (inheriting) the library class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With