Back

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

I am currently learning Python and I have arrived at the segment about the pass articulation. The guide I'm utilizing characterizes it similar to a Null explanation that is normally utilized as a placeholder. 

I actually don't completely comprehend what that implies, however. Would someone be able to show me a basic/essential circumstance where the pass proclamation would be utilized and why it is required?

1 Answer

0 votes
by (26.4k points)

Let's say, you are creating a new class with some other methods which you don't want to implement, yet

class MyClass(object):

    def meth_a(self):

        pass

    def meth_b(self):

        print "I'm meth_b"

Assume you are planning another class with certain strategies that you would prefer not to actualize, yet. 

class MyClass(object):

    def meth_a(self):

        pass

    def meth_b(self):

        print "I'm meth_b"

If you somehow managed to leave out the pass, the code wouldn't run. 

You would then get an: 

IndentationError: expected an indented block

To sum up, the pass explanation does nothing specific, however it can go about as a placeholder, as shown here.

Interested to learn python? Join python course to gain more knowledge 

Related questions

0 votes
1 answer
asked Oct 11, 2019 in Python by Tech4ever (20.3k 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

Browse Categories

...