Python 3-3 functions and methods

The difference between python functions and methods

1. Classification

1. Classification of functions:

  • Built-in functions: some functions embedded in python.
  • Anonymous function: A line of code implements a function.
  • recursive function
  • Custom function: Define the function according to your own needs.

2. Classification of methods:

  • Instance method: a method called directly with self.
  • Private method: __ function name, a method that can only be called in the class.
  • Property method: @property, disguise the method as a property to make the code look more reasonable.

Guess you like

Origin blog.csdn.net/weixin_43955170/article/details/113105522