Turn off functions or classes

Can you explain the concept stubbing out functions or classestaken from in this article ?

class Loaf:
    pass  

This class does not define any methods or attributes, but there should be something syntactically in the definition, so you use pass. This is a reserved word in Python, which simply means "move forward, see nothing here." It is an expression that does nothing, and it is a good placeholder when you execute functions or classes.

Thank you

+5
source share
4 answers

execution of functions or classes

This applies to writing classes or functions, but not to their implementation. For example, maybe I am creating a class:

class Foo(object):
     def bar(self):
         pass

     def tank(self):
         pass

, . , . :

class Foo(object):
     def bar(self):
         raise NotImplementedError

     def tank(self):
         raise NotImplementedError

, , , .

+15

A 'stub' - - , , , . , (, ), .

Stubbing - , :

  • : , , , , , .
  • : Stubbing ; , . .
  • . , , .
+4

pass , Python (, class function).

( ), - , pass . - :

class Loaf:
    True

( , pass, ).

+1

Stubbing - . , , , UML-, .

, , , . , . , , , .

+1

All Articles