Why should I learn Python (1)

Source: Internet
Author: User

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:

 
 
  1. def a_plus_b(a,b):  
  2. 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.

 
 
  1. def use_duck( Duck ):  
  2. Duck.swim()  
  3. Duck.gaga()  
  4. class Duck:  
  5. def swim(self):  
  6. ...  
  7. def gaga(self):  
  8. ... 

If you use

 
 
  1. little_duck Duck()  
  2. 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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.