Introduction: I have been studying Python for nearly two years. I have a little understanding of Python, and I have also talked about my own meager ideas in some aspects, that is why I have learned Python.
Here I will not discuss some useful libraries or frameworks of Python. I will talk about this language only when the language itself is the least supported.
Language Development is getting closer and closer to Lisp, which is also the reason for the greatness of this language.
The following lists the reasons why I learned Python:
I. Multi-Programming Paradigm
Python is a multi-paradigm programming language. It is called a process-based, object-oriented, and functional combination.
Most people start from procedural programming languages because procedural programming methods are consistent with computer running methods, and command sequences and running processes are consistent.
For example, in typical C, I also started to learn from C. The process-based programming language design is relatively simple, but it is in line with human-computer interaction.
Although Python is an object-oriented language, even "" spaces) can also be seen as an object, but Python is competent in the process.
If you do not need to use static methods of the class:
- def a_plus_b(a,b):
- return a+b
When designing python, it is written as an object-oriented method, not to mention some revolutions brought by object-oriented software design, one of the highlights of object-oriented dynamic languages like python is the Duck typing Duck type)
Regarding the duck type, that is to say, if I think an abstract thing will be swimming, it will be "grack" and I can treat it as a duck.
- def use_duck( Duck ):
- Duck.swim()
- Duck.gaga()
- class Duck:
- def swim(self):
- ...
- def gaga(self):
- ...
If you use
- little_duck Duck()
- use_duck( little_duck )
For the Duck class, you can give it any name, or inherit it from another name. You only need to implement swim () gaga () And you can regard it as a Duck
Many people do not understand why they do not need to provide an interface to regulate the behavior of ducks. I neither support nor disagree. My point is as follows:
1. The parameter check does not conform to the Dynamic Language Features
2. The interface specification is provided, so it is not a duck type. It is called polymorphism directly.