Interview Python: Pass keyword

Mateusz Kubaszek
2 min readJul 26, 2021

--

  • What is the pass ?

The pass is a special word in Python that we can use to mark that code should be omitted.

  • Why we should use it?

Mostly we could use it to mark some chunk of code that will be implemented later. That approach is very useful by using the TDD and “abstraction first” methodology.

  • Examples:

The first one shows you how we can use pass. Now is easy to modeling some abstraction. That approach could help us to create many functions/classes and connect them into one system.

Note:

What the above `print` should return? For every method that hasn't return a statement explicitly, Pythono’s interpreter will implicitly add return None So every pass in code, you can treat as return None .

Finally, you can use it while creating class structure.

Now you can see how easily we can move from function prototype to new classes that are necessary for our function’s implementation.

Note:

There is one trick by using semicolons.

What should be printed in the terminal? Check it ;)

--

--