Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stubbing out functions or classes

Can you explain the concept stubbing out functions or classes taken from this article?

class Loaf:
    pass  

This class doesn't define any methods or attributes, but syntactically, there needs to be something in the definition, so you use pass. This is a Python reserved word that just means “move along, nothing to see here”. It's a statement that does nothing, and it's a good placeholder when you're stubbing out functions or classes.`

thank you

like image 268
xralf Avatar asked Oct 01 '11 13:10

xralf


1 Answers

Ellipsis ... is preferable to pass for stubbing.

pass means "do nothing", whereas ... means "something should go here" - it's a placeholder for future code. The effect is the same but the meaning is different.

like image 155
Beau Barker Avatar answered Oct 05 '22 23:10

Beau Barker