
In the world, everything is roughly distributed according to the Pareto principle. The smaller part is the rich, the majority is the poor (reading, you enter the golden billion). The same applies to materials about programming. Sometimes it is very difficult to find at least something not entry level.
After reading
Dive into Python or similar and reading the documentation, the question arises, what to read next? You can refer to the
list of books on python.org. There is a section of
Advanced Books , but there are only 6 books in it (the seventh did not come out), and I would call only one really worthwhile.
Fortunately, Python has very detailed and high-quality documentation. But even in it, many topics are either only superficially affected, or they are very difficult to find (because the documentation is large, and if you do not know where to look, you will not find it).
')
Below are collected complex materials about Python, its structure and capabilities. Everything is in English (sin, do not know technical English). About
Dive into Python, I went astray. Most of these materials require a good knowledge of Python and programming experience on it.
Articles from official documentation
Data modelBasic article about objects in Python. It is necessary to know by heart (truth-truth). Without it, further understanding how Python works is almost impossible. I would also like to focus on:
- Implementing Descriptors . In my opinion, descriptors are the best, unsurpassed, possibility of Python, but at the same time the most underestimated. Now they are mostly used only in frameworks. It will be necessary, somehow, to write how descriptors simplify development and improve the quality of the code.
- Customizing attribute access . And the first thing you need to read about is the difference
__getattribute__
and __getattr__
. - Special method lookup for new-style classes . Important: access to magic methods happens to bypass
__getattribute__
if you just do not call them directly ( len(obj)
and obj.__len__()
).
ExceptionsExceptions must deal with inheritance (
PEP 352: Exceptions as New-Style Classes ). In Python 2.4,
Exception
is a classic class, not the
object
's subclass. In Python 2.5,
Exception
already inherits
BaseException(object)
, i.e. this is a new class. Also note that in version 2.4
KeyboardInterrupt
and
SystemExit
inherit
Exception
, and in 2.5 -
BaseException
.
I also recommend to directly take and compare (put two windows side by side) the
hierarchy of exceptions in Python 2.4 and the
hierarchy in Python 2.6 (compared to 2.5, only a few classes were added).
Articles about classes, attributes and methods
Unifying types and classes in Python 2.2 , Guido van RossumAn article from the creator of the language about what new-style classes are. I think it is not necessary to write why it should be read (better, several times).
The Python 2.3 Method Resolution Order , Michele SimionatoHow is the calculation of the order of access to methods (MRO) and attributes in multiple inheritance. The new classes can be obtained through the attribute
__mro__
.
Shalabh Chaturvedi:Very good and great books-articles + beautifully composed.
Python Types and ObjectsHow
type
and
object
correlate.
Python Attributes and MethodsHow is access to the attributes in the new classes, the difference of functions and methods, descriptions of descriptors and MRO.
Be pythonicA brief, not so important article, how to write code in the style of Python (added only to list all the articles of the author).
Metaclasses
I would like to cite one [very famous] quote about metaclasses:
English
[Metaclasses] are deeper magic Metaclasses are complex magic,
than 99% of users should ever about which 99% of developers even
worry about. If you wonder not to worry. If you
Whether you need them, you ask if you need them
don't (the people who are actually metaclasses, you know, they don’t
with people who need them
that they need them, and don't really need them, absolutely
they are sure of this, and they do not need
Tim Peters (clp post 2002-12-22) explanation why).
(very bad that you do not know
English, this article links
only on English-language materials)
It is easier to insert as monospace than trying to portray a table with cells without the width attribute, not to mention the styles. I honestly tried for about 20 minutes.So,
it is not . If you don't know metaclasses, you don't know Python. Now, after motivation, you can return to the articles.
Customizing class creationOfficial documentation.
Python Metaclasses: Who? Why? When? , Mike Fletcher , PDF
There are many practical examples of how and why
you can [but often
do not need the author.] To use metaclasses.
Metaclass programming in Python , Part 2 , Part 3 , David Mertz, Michele SimionatoVery detailed articles, all sorted out by bone. The only BUT: very boring and academic written. Although it is possible that this is just my prejudice to articles on IBM DeveloperWorks.
Metaclasses in Python 3000, PEP 3115Metaclasses in the third Python. The main differences are the ability to pass kwargs directly into the class definition of
class Foo(*bases, **kwargs)
and support for the
__prepare__
function, which should return mapping for class attributes, such as an ordered dictionary.
In general, about metaclasses: know, know and know again. But! If you decide to use them, think, then think again and, nevertheless, try to do without them ;-D.
Articles on other topics
Python 401: Some Advanced Topics , PDF
The best and
most detailed explanation of string interpolation (
'Hello, %s.' % username
). Plus iterators, generators, descriptors, metaclasses, why methods are slower in functions (because an object is created with each call), etc.
How-To Guide for Descriptors , Raymond HettingerHow descriptrats work, how to invoke and use them.
David BeazleyHe writes very good, and most importantly, practical articles. Only he can read how to parse the Apache log with the help of generators or how to write an “operating system” on quiche.
Inside the python gilHow Global Interpreter Lock works and why using threads in Python can slow down a program.
Inside the New GIL (Python 3.2)Description and tests of the new GIL, which will be in Python 3.2 (and maybe will be ported to 2.7).
Generator Tricks for Systems Programmers , Version 2Practical use of generators and their advantages (speed + low memory consumption).
A Curious Course on Coroutines and ConcurrencyWhat is Korutin and why it is necessary to clearly distinguish them from conventional generators (they have different functions: some give out data, others process them). At the end, he will write an analogue of the operating system on them.
My recommendationsSee the result
dir(method)
and
dir(func)
. Read the help for
new
,
itertools
,
functools
. Be sure, if you still do not know, get acquainted with the functions
map
,
reduce
,
zip
and
filter
(a map can take many iterators at once).
Read about
Abstract Base Classes and Collections. And not only in Python, but also in
Java . ABC largely follows its trail.
Visit the site of
PyCon , the annual developer conference. Materials of past conferences are also available there (although often
not available). It is necessary to look in
Conference / Schedule .
I almost forgot, be sure to read the
Python Cookbook . This practical book is simply superb. How to quickly sort using the decorate-sort-redecorate method, which sorting algorithm Python uses (insertion sort for a small number of elements and timsort for a large one), how to work with XML, dynamically create modules and much more.
Conclusion
Wrote that he remembered or found in bookmarks. I hope many will help. Also do not forget
ipython and it? and ?? .. (for those who do not know, this is a very powerful interactive shell for Python, and the questions show information about the objects, for example,
import sys; sys?
). May the power come to you.