What are some of the code snippets in Python that are worth reciting dictation?

Source: Internet
Author: User
These code snippets or programs, look smart, or quite practical, worth collecting

Reply content:

Write code, do not test, do not need Beethoven (back multi-points) that year is to not use the endorsement of the computer Ah! (Serious face

This knowledge, is in the process of playing deeply engraved in the mind. Just like a little bit of gas is a small attack, shipped three is the air cannon, deep engraved in the mind AH (what I'm talking about

That year, I think the handwriting prime sieve good cow ah, this must be back down.
Later write more know, Prime sieve, fast power, there is a simple DP search segment tree write more can directly look at the problem knocked out again. When you are familiar with each operator, each of the constants in the algorithm's role, it is very natural to write it in a graceful structure.

When I see Daniel Whiteboard writing algorithms I've never seen before, I'm not as surprised as I used to be. Because I know that it is not recited, he must have paid more than I work in that field.

-----

Collection of course or PyPI best, just copy the words with the module is the most convenient bar from the engineering point of view is to extract enough code, and then find the highest frequency of snippet, such as a row (may be #coding: utf-8) such as more than two lines. Except ...:

Then, it's no use for birds. If there is anything to recite, I think it is the logging configuration. The Lord may want to ask where Python learns to make dread. Standard library usage back, such as the Urllib series, re. And the use of basic objects. Python itself is flexible, and a feature is often written in many ways. I don't think I need to recite.
If you want to say the practical code, you can write it for the first time, then import it directly by importing ... If a code snippet is worth reciting, it will certainly be packaged as a module or package, and you just have to use it. Print (' Hello world! ') Not really. You're going to build your own lib in the future, it's time to import it. Remember some best practices ... You don't have to have an impression on your back.
  • 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.