11 knowledge points required for getting started with Python and python

Source: Internet
Author: User

11 knowledge points required for getting started with Python and python

Python is known as an efficient programming language all over the world and also known as a "glue language". Why is it so popular? Let's talk about 11 essential knowledge points for getting started with Python, that is why it is so popular.

Python Introduction

Python is a high-level scripting language that combines interpretation, compilation, interaction, and object-oriented.

The Design of Python is highly readable. Compared with other languages, it often uses English keywords and some punctuation marks in other languages. It has a more distinctive syntax structure than other languages.

Python is an interpreted language: this means that compilation is absent during development. Similar to PHP and Perl.

Python is an interactive language: this means that you can directly interact and write your program at a Python prompt.

Python is an object-oriented language: this means that Python supports the object-oriented style or code encapsulated in the object programming technology.

Python is a beginner's language: Python is a great language for beginners. It supports a wide range of application development, from simple text processing to WWW browsers to games.

Python Development History

Python was designed by Guido van rosum at the National Institute of mathematics and computer science in the Netherlands at the end of 1980s and the beginning of 1990s.
Python itself has evolved from many other languages, including ABC, Modula-3, C, C ++, Algol-68, SmallTalk, Unix shell and other scripting languages.
Like Perl, Python source code also complies with the GPL (GNU General Public License) protocol.
Currently, Python is maintained by a core development team, and Guido van rosum still plays a crucial role in guiding its progress.

Python features

1. Easy to learn: Python has fewer keywords, and its structure is simple. It is easier to learn with a clearly defined syntax.

2. Easy to read: Python code definition is clearer.

3. Easy Maintenance: Python's success lies in that its source code is quite easy to maintain.

4. A wide range of standard libraries: one of the biggest advantages of Python is the rich library, cross-platform, and compatible with UNIX, Windows, and Macintosh.

5. Interactive Mode: supports interactive mode. You can enter the language from the terminal to execute the code and obtain the result, interactive testing and debugging code snippets.

6. Portability: Based on its open source code features, Python has been ported (that is, to make it work) to many platforms.

7. scalable: If you need a piece of key code that runs very fast, or want to write algorithms that are not open, you can use C or C ++ to complete that part of the program, and then call it from your Python program.

8. Database: Python provides interfaces for all major commercial databases.

9. GUI programming: Python supports GUI creation and porting to many system calls.

10. Embedding: You can embed Python into a C/C ++ program, allowing users of your program to gain "scripted" capabilities.

1. What application scenarios does Python apply?

There is no fixed answer, and many people say that Python is not suitable for developing GUI programs, but Python's own IDE--IDEL and third-party IDE-Eric is written by Python.

Currently, more people are using the Web, such as Django and web. py frameworks. If you remember correctly, Flask is also used.
There is also a situation where Python is used as glue and combined with various languages to complete a software function, note that you may find Python installed.

I personally used Python to simulate port forwarding and DNS services, so it really depends on what it is, rather than how it can be used.

In addition, Python is suitable for big data analysis. From loading to analysis, to saving results, Python has a complete set of modules.

2. Is Python competent for big data?

Python is suitable for big data-related analysis. The built-in C-compiled module can handle common operations. For some extreme algorithms, we recommend that you use C to rewrite relevant modules.

Python itself features more efficient development and simple maintenance, and the speed is handed over to C. More problems are actually not used by code writers, rather than being inefficient. For example, for sorting, Python has a very efficient built-in C compiling module, But it is strange to write algorithms on its own.

In addition, it depends on whether the requirement is CPU-intensive or I/O-intensive. If it is CPU-intensive, we recommend that this part of the operation be implemented by C. The IO-intensive efficiency will not change much because of Python.

The efficiency of C is high, but the framework is also difficult to set up, so it should be combined. Therefore, Python is called the glue language.

3. Can Python completely replace Shell?

The Shell function can be fully implemented in Python, with less code, better structure, and better readability. The Shell function that Python can implement is not necessarily possible, for example, the Socket module for network communication, the Django framework for WEB, and the psutil module for performance collection are used in O & M. In addition, Shell is highly dependent on operating system commands, python can be avoided to a greater extent.

A Shell IDE is a big problem. Although Python's native IDE is not very good, the third-party IDE is still very powerful, although it cannot be comparable to Microsoft's Virtual Studio, but it can fully meet the development needs of Python.

Let's talk about the efficiency of Python. Python supports multi-process, multi-thread, and coroutine (a lower level than the thread), and the program concurrency is based on Shell. The core modules of Python are basically implemented in C, so the efficiency is higher. If necessary, rewrite the Python module that needs to be implemented using Python to improve efficiency. Of course, you can also directly use C Python, a Python interpreter that is directly implemented using C.

4. Can Python access common databases?

Yes. Python can access common databases, such as Oracle, MySQL, Vertica, and SQLServer, and load corresponding modules. The list of modules is as follows:
Oracle: cx_Oracle
MySQL: MySQLdb

5. Is Python development process-oriented, function-oriented, or object-oriented?

Although Python is an interpreted language, it has been an object-oriented language since its design. For Python, everything is an object. Because of this, it is easy to create a class and object in Python. Of course, if you are used to writing process-oriented statements or functions, Python does not impose hard limitations.

Python has the following object-oriented features:

Encapsulation

The term Object in Object-Oriented Programming can basically be seen as a collection of data (features) and a series of methods that can access and operate the data. In the traditional sense, "program = Data Structure + algorithm" is encapsulated and "hidden" and simplified to "program = Object + message ". Objects are instances of classes, and class abstraction needs to be encapsulated. Encapsulation allows the caller to directly use the object without worrying about how the object is constructed.

Inheritance

Class inheritance:

The direct sense of inheritance is that it is a behavior of reusing code. Inheritance can be understood as it is based on ordinary classes to establish a special class object, subclass and its inherited parent class is the relationship of IS-A.

Multiple inheritance:

Unlike C #, Python supports multi-class inheritance (C # can inherit from multiple interfaces, but can inherit from a maximum of one class ). Multiple inheritance mechanisms are sometimes useful, but they make things more complex.

Polymorphism

Polymorphism means that the same operation can be performed on different objects, but they may present results in multiple forms. In Python, polymorphism is used when you do not know the object type, but need to do something about it. Methods are polymorphism and operators are also polymorphism.

6. How to quickly master Python?

You can read the official documents to meet your daily needs. The official documents are translated into Chinese, making it easier to learn. However, these are basic syntaxes and common modules. To learn Python, the module is important. rapid and efficient development depends on the application of the module. standing on the shoulders of predecessors will save time and effort.

But the most important thing to learn about Python is the learning module, rather than the syntax itself. The syntax of Python is very simple. As long as a university has studied C or data structure courses, even those who have never learned it can easily master it. Having mastered the syntax, You can implement Shell functions, but it is essential to improve the module learning. For example, O & M personnel often use the following:

Psutil: Get performance information

Socket: Basic Network Communication

IPy: IP address related processing

Dnsptyhon: domain name Processing

Difflib: file comparison

Pexpect: screen information acquisition, often used for automated

Paramiko: SSH client

XlsxWriter: Excel Processing

There are many other multi-functional modules, and new modules, frameworks, and components are constantly generated every day. For example, PythonJS is used to bridge with Java, and even Python can write Map and Reduce.

7. Does Python have a dedicated IDE tool?

Yes, IDEL is a Python IDE tool implemented in Python, but to be honest, the functionality is really bad. My commonly used IDE is as follows:

PyCharm

PyCharm is a Python IDE developed by JetBrains. PyCharm is used for general IDE functions, such as debugging, syntax highlighting, Project management, code jump, smart prompts, Automatic completion, unit testing, Version Control ...... In addition, PyCharm also provides some good functions for Django development and supports Google App Engine. What's even cooler is that PyCharm supports IronPython!

Wing IDE

Python IDE of Wingware is compatible with Python 2. x and 3.xcan be combined with Django, matplotlib, Zope, Plone, App Engine, PyQt, PySide, wxPython, PyGTK, Tkinter, mod_wsgi, pygame, Maya, MotionBuilder, NUKE, blender and other Python frameworks. Wing supports test-driven development and integrates the unit test, nose, and Django framework execution and debugging functions. Wing IDE starts and runs very quickly. It supports Windows, Linux, OS X, and Python versi.

NotePad ++

Simple and Convenient, but only suitable for temporary changes.

Others: Eclipse withPyDev, Sublime Text, Komodo Edit, Pyer, The Eric Python IDE, Interactive Editor for Python

8. What are the common methods for automated system monitoring using Python?

To be accurate, what modules should be available? Health Monitoring must have psutil to monitor performance. Communication Socket, login Paramiko, telnetlib, and ftp ftplib will also be used.

The basic principle is to collect data-process data locally-transfer data. If you are doing well, you can make another presentation of data, or send the data to Zabbix and other open-source tools.

I also use an open-source monitoring network, which is automatically blocked when the specified number of times is exceeded.

9. Which platforms can Python run on? How cross-platform?

Supports common mainstream platforms, such as AIX, HPUX, Solaris, Linux, and Windows. Except Windows, Common Unix and Linux platforms all have native Python, but the version is generally low. As for cross-platform and cross-platform languages, you must note that some modules are unique to a single platform, and the overall cross-platform performance is good. You do not have to write multiple sets of code to adapt to multiple platforms.

This does not mean that there are no restrictions: first, the intermediate file of the same version. py and. pyc and. pyo is cross-platform. Second, PCs and mobile terminals, such as mobile phones and tablets, cannot be cross-platform (see the next article for the reason). Finally, they cannot be cross-processor architectures, such as Intel and ARM, 64-bit and 32-bit.

10. How can I use Python to improve development efficiency?

Because many underlying things of Python do not need to be written by themselves, and the module resources are rich. The proper use of the development efficiency will certainly improve, and various frameworks also provide the foundation for rapid development.

11. How fast is Python running?

Generally, Java is faster than Python. Except Python calls the C extension (CPython can also be used directly ).
The Python language author Guido van rosum said:

If the system you develop finds the performance bottleneck, the most efficient way is to find the problematic code block, replace the function or module with code written in a faster language such as C or C ++, instead of rewriting the entire system with C or C ++, because for most of the Code, language speed is irrelevant.

Learning is a person's greatest accomplishment. Learning can not only improve his own realm, but also enrich his knowledge, lay the foundation for future employment. Learning Python is also a good opportunity to develop himself, after all, the AI age has arrived. As the main force of the AI age, Python is very promising. Its dream is not decaying, And there is sweat flow along the way. Come on!

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.