pass
does nothing. It's a filler to let the code run before you implement something. The libraries are probably using pass
to:
- Leave blank code to finish later
- Create a minimal
class
:
- Imply that a section of code does nothing
- Loop forever (and do nothing)
So to your question about libraries, they probably do nothing. pass
on its own is almost as good as a blank line, but can be mixed with functional statements to achieve a working module. But the function in your question does nothing at all.
Say I wanted to keep a function f
in my file, and come back to it later. I could use pass
to avoid IndentationError
:
>>> def f():
... pass
...
>>> f()
>>>
As without pass
, I'd have:
>>> def f():
...
File "<stdin>", line 2
^
IndentationError: expected an indented block after function definition on line 1
>>>
This is also explained in the offical docs:
The pass statement does nothing.
It can be used when a statement is required syntactically but the program requires no action. For example:
>>> while True:
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
...