What code snippets are worth memorizing in Python?

Source: Internet
Author: User
These code snippets or programs look clever or practical. They are worth adding to your favorites. They look clever or practical and worth adding to your favorites: write code, do not take the test, do not need Beethoven (back more points) that year is to not endorse the computer learning ah! (Serious face

These knowledge is deeply imprinted in my mind during the course of playing. Just like a small attack and an air cannon, it is deeply printed in my mind (what am I talking about?

I thought that the handwriting prime number screening was good. This must be memorized.
After writing more, you will know that the prime screening, fast power, and a simple dp search line tree can be written more, and you can directly read the question and knock it out again. When you are familiar with every operator and the role of every constant in the algorithm, it is very natural to write it out according to the beautiful structure.

I am not surprised when I see some algorithms I have never seen on the big boys whiteboard. Because I know that this is not what I recite, he must have made more efforts in that field than I did.

-----

If you add to favorites, PyPI is the best. If you just copy it, it is the most convenient to use the module. From the engineering point of view, it is necessary to extract enough code and then find the most frequently-occurring snippet, for example, a single line (may be # coding: UTF-8), for example, two or more lines. else t...:

Then there is nothing to use. If there is anything to carry back, I think it is probably the configuration of logging. The subject may want to ask, where should python learn. The standard library uses a back-to-back method, such as the urllib series and re. And the use of basic objects. Python itself is flexible, and there are often many ways to write a function. I personally think it is not necessary to recite ..
If you have to describe practical code, you can write it for the first time, and then import it directly using import... If a code snippet is worth memorizing, someone will encapsulate it into a module or package. You just need to use it and print ('Hello world! ') No .... You can create your own lib and import it as soon as it is used. Just remember some best practices ...... You don't have to worry about it ......

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.