The pass
statement does nothing.
Wow, that's a bummer!
Hmmm...
Then, why do we need it?
Well, it can be used when a statement is required syntactically but the program requires no action.
Let's see an example:
This is also commonly used for creating empty classes so that we can come back later and code something:
Another place pass
statement can be used is inside a function:
Note:
- The body of any statement containing
pass
statements are ignored by the python interpreter, just like it ignores comments.
Best Resources
Python Blog Series : A Blog series where I will be learning and sharing my knowledge on each of the above topics.
Learn Python for Free, Get Hired, and (maybe) Change the World! : A detailed roadmap blog by Jayson Lennon (a Senior Software Engineer) with links to free resources.
Zero To Mastery Course - Complete Python Developer : A comprehensive course by Andrei Neagoie (a Senior Developer) that covers all of the above topics.
Who Am I?
I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath
Thank you so much for reading my blog🙂.
Top comments (0)