Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (20.3k points)

I am in the process of learning Python and I have reached the section about the pass statement. The guide I'm using defines it as being a Null statement that is commonly used as a placeholder.

I still don't fully understand what that means though. Can someone show me a simple/basic situation where the pass statement would be used and why it is needed?

1 Answer

0 votes
by (119k points)

Pass statement is a null statement noting but a place holder for future code. The interpreter in python does not ignore the pass statement but sends the statement to no operation. Pass statement is used to ignore the compilation errors and to hold the place for code which you want to implement later. 

For example, if you want to implement a class with some functions that you want to implement in future but not now.

class myClass(object): 

    def function1(self)pass
    def function2(self): pass

If you want to become a expert in Python, I recommend this Python Certification program by Intellipaat that provides Instructor-led training, hands-on experience, and certification also.

Related questions

0 votes
1 answer
asked Dec 11, 2020 in Python by laddulakshana (16.4k points)
0 votes
1 answer
asked Jul 15, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Sep 20, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Sep 17, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...