Python Modules most worthwhile reading

前端 未结 4 840
一向
一向 2021-01-29 23:42

I have been programming Python for a while and I have a very good understanding of its features, but I would like to improve my coding style. I think reading the source code of

相关标签:
4条回答
  • 2021-01-30 00:12

    Queue.py shows you how to make a class thread-safe, and the proper use of the Template Method design pattern.

    sched.py is a great example of the Dependency Injection pattern.

    heapq.py is a really well-crafted implementation of the Heap data structure.

    If I had to pick my three favorite modules in the Python standard library, this triplet would probably be my choice. (It doesn't hurt that they're all so very useful... but I'm picking in terms of quality of code, comments and design, first and foremost).

    0 讨论(0)
  • 2021-01-30 00:13

    I am learning Django and I really like their coding style,

    http://www.djangoproject.com/

    0 讨论(0)
  • 2021-01-30 00:18

    PEP 8 is the "standard" Python coding style, for whatever version of "standard" you want to use. =)

    0 讨论(0)
  • 2021-01-30 00:24

    I vote for itertools. You'll learn a lot of functional programming style from using this code, though perhaps not from reading the source.

    For a good module-by-module tutorial, try Doug Hellmann's Python Module of the Week. I also like the python programming style/practices explored and developed at WordAligned. I also like Peter Norvig's code, especially the spelling corrector code and the sudoku solver.

    Other cool modules to learn: collections, operator, os.path, optparse, and the process/threading modules.

    0 讨论(0)
提交回复
热议问题