Python: Pass Statement with Examples — ArrayJson
In this article, we will discuss the ‘ pass ‘ statement of python, it’s syntax, how and when to use it with examples.
What is a Pass statement?
‘pass’ is a statement in Python that does nothing. It is a null operation which tells Python interpreter to just go on without doing anything.
class Foo: pass # do nothingGet Arrayjson.com’s stories in your inbox
Join Medium for free to get updates from this writer.
Syntax
The syntax of the pass statement is just the string ‘pass’ without parenthesis and all letters in lowercase.
How Python interpreter treats pass statement?
Unlike comment which gets ignored, Python interpreter executes the pass statement but does nothing.
When and how to use pass statement?
As per the documentation of Python, a pass statement can be used when there is a requirement to follow the syntax for a program that does not require execution(yet). For example, declaring an empty class like below:
class Foo: passOriginally published at https://arrayjson.com on May 13, 2020.
