[Python] Python Getting Started Guide

Source: Internet
Author: User
Reprinted from Ref: http://shell909090.com/blog/2012/11/python%e5%85%a5%e9%97%a8%e6%8c%87%e5%bc%95/
Python Getting Started Guide


Posted on 2012
January 1, November 19

Preface

In fact, I don't know how to get started with python. It is really not suitable for me to write this. I learned python by looking for dive into Python directly. Then I wrote several examples. In about two days, you will be on the road. It's like taking chopsticks. I don't even remember how to learn how to take chopsticks. How can I teach people?

However, recently, in the python-CN list, I have been seeing "which tutorial is better at getting started with Python" for weeks, which is really disturbing. Simply write a simple guide for anyone who is interested to read it. Heartless-I can't help it anymore.

Basic knowledge

First, you need to understand one thing. Many things you don't know do not belong to Python. For example, you do not know the network communication process, you do not know the file permissions and open flag usage, and you do not know the relationship between fork and stdin/stdout. These python will not teach you. If you lack the relevant knowledge that is irrelevant to the language/database, make up your own lessons. If you lack basic computer theory, make up your own lessons.

Therefore, do not send me an email, leave a message, or ask me why this problem cannot be solved in Python. Why can't Python be seen and obtained? Why can't Python be hot deployed? Why can't Python be used for Embedded Development. Before asking this question, confirm "this is a python question ". For example, Gil or brainless lambda. If you are not sure, search for related articles and confirm them. Before asking a question, let's take a look at the wisdom of asking questions ". If you have searched and cannot find it, ask, no way.

Getting started

On the Internet, the two basic books for getting started with Python are ):

  • A byte of Python Chinese Version
  • Dive into Python Chinese Version
  • Learn python the hard way, 2nd Edition Chinese Version

I recommend that you skip a bunch of missing Python-doc files and directly view the library.
Reference. Python itself is an extremely easy-to-use code. The documentation is quite beautiful, And the built-in libraries are comprehensive. In most cases, Python-doc should be able to solve your problem.

Web

Web is a major target for programmers. A framework required for getting started with Python programmers is Django. Don't worry about it. Django is too famous in the python community and uses too many people. Therefore, the most entry-level materials are provided, the largest community, and the lowest threshold. If you want to get started with the Web, you must start with Django. If you are not familiar with python, I do not recommend that you start with other frameworks.

Of course, if you are familiar with python, consider getting started with the Web framework. For more information, see the special section.

Crawler

In python, scrapy is the first choice for Crawler development. The reason is the same as above. The community is the largest and most people are used. If it is not easy to use, you will be wise. All of my crawler frameworks use their own gevent-based libraries.

UI

There are also many Python UI frameworks, which are very complicated. Similarly, for beginners, we recommend that you start with the two frameworks of QT, pyqt and pyside. I am not talking nonsense about the two families.

Specializations

The so-called specializations refer to the use of python in specific work. We are divided into several fields.

System and deployment
  • Virtualenv: This is recommended for deployment in commercial environments. Python can be embedded in the source code to avoid migration/integration issues.
  • Python-daemon: it is convenient to write daemon.
Network

When it comes to the network, it is basically in addition to the Web.

  • Twisted: a very powerful network library with comprehensive support for various protocols, but the reactor mode is really tangled.
  • Gevent: a network library in asynchronous coroutine mode.
  • Scapy: powerful network library.
  • Pyzmq: I never thought zeromq was an MQ. I think it is an abstract network layer.
Web Container

A major feature of the Python web framework is that containers/frameworks/ORM/templates can be played independently.

Note that the container and framework are two different cases. A container is a Python web running environment, and a framework is a tool for parsing the environment. The two are generally connected using the wsgi interface. This is the standard practice of Python. FastCGI/scgi will also be converted to wsgi for connection. But there is no other choice. Generally, we have the following modes:

  • CGI: the CGI Module is included in Python-Doc.
  • Mod_python: Embed in Apache.

The following is the container of the wsgi interface. The advantage of wsgi is that we can run any wsgi-supported framework on these containers.

  • Flup: supports FastCGI, scgi, and AJP interfaces. Web servers can use these three protocols for connection.
  • Google App Engine: PAAs service.
  • Gunicorn: provides HTTP services directly.
  • Mod_wsgi: Use the internal protocol to integrate with Apache.
  • Twisted: provides HTTP services directly.
  • Tornado: provides HTTP services directly.
  • Uwsgi: Use the internal protocol to integrate with nginx.
  • Werkzeug: provides HTTP services directly.

The recommended deployment mode is to use Apache to demode_wsgi. Use nginx to go to uwsgi. It is available directly with Gae. Others.

Web

You can refer to this article by referring to several frameworks. You can try it out without any trouble, and then select the one that best suits you.

Zope is one of the things that must be mentioned in Python. I don't know how to rate this. If you are interested, let's take a look.

ORM

Orm: the python ORM system is relatively simple, generally sqlalchemy. This framework is very powerful but resource-consuming. If you are interested, go to the official website to learn about it. Occasionally, there are not many sqlobject users.

Another major choice of ORM is zodb, but it is rarely used. If you want to know about it, consult laopan.

Template

An article on Python wiki mentions the classification and list of Python template engine. As an expert, I suggest you at least play string. template, webhelpers, Mako, jinja2, and genshi.

Crawler

It is hard to say that python crawlers are advanced. I am writing a long blog to introduce various Python crawlers. But at least you need to know the following things: Celery, beautifulsoap, lxml, selenium, phantomjs, and pyquery.

UI

The list of GUI Libraries can be viewed here. I recommend that you take a look at pygtk, tkinter, wxpython, Glade, and pygame.

Scientific Computing

You can read this document and use python for scientific computing. The author has published a book. You can support it.

Graphic Processing

Pil and Python imaging library must be mentioned. In addition, we will introduce pydot, pygraph, or pygraphviz. This is not a graph library. To be precise, it should be a graph library. He can use graphviz to convert Graph Theory to an image.

Document
  • Pygments: the Library for formatting code. You can format text code in different formats with color.
  • Markdown: format the markdown document as an HTML library. However, I think it is useless to implement different standards.
  • Restructured: The docutils tool group, which can be converted to multiple formats.
  • Sphinx: The same rst tool can generate multiple formats.
Advanced

First, you should go to Shen youxia's speech at a cpug party to see the python programming art. This is an advanced step for python programmers. However, it is a pity that slide is a stream of Takahashi, and it is not intended for you to see the content. There was no video at the time of the Speech (if any, Please copy it to me. I will ask Shen youxia if he can release the video, find a space, and solve the problem. Thank you ), therefore, it is quite difficult to understand. However, every sentence here is quite reasonable. It is a summary of decades of program experience.

In addition, as an advanced tutorial, you can view some content of python3. Dive into Python
3. There are also pypy and cython.

As an advanced Python developer, you must prepare a source code for a frequently-used release without having to make the minor version consistent. At least the major version is consistent (2.7.x, and the last one can be non-aligned ). Read the source code, especially the objects directory. Read Python-Doc again frequently.

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.