+ 5

What is the use of "pass" in python?

6th Feb 2018, 8:34 PM
WhoamI
WhoamI - avatar
3 Answers
+ 9
I use it as a placeholder when designing a class or defining a function. Just so the code would be runnable. Then I fill in the "blank" :)
6th Feb 2018, 9:23 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 8
In other languages you've learned, you get the same effect with a ; without a statement. It is a null statement. Allowing this code to find the first 5 in the array. while x[i++] != 5: pass
6th Feb 2018, 8:47 PM
John Wells
John Wells - avatar
+ 4
pass Is used as a null object, when you still do not have the structure of your function, put it inside and you won't get any error.
8th Feb 2018, 3:55 AM
Marko