Smooth python PDF download HD full scan original

Source: Internet
Author: User
Tags closure new set macbook intel core i7 intel core i5

The title: Fluent python
Brazil Luciano Ramalho
Translator: Andorra Wu Ke

Friends who need to learn can download PDF version of the Web disk.

Target Audience
This book is intended for programmers who are using Python and who want to familiarize themselves with Python 3.
If you know Python 2, but want to migrate to Python 3.4 or later, and don't ask
Problem. In writing this book, most professional python programmers use Python 2,
So if the book comes with features from Python 3, the reader may feel unfamiliar and I will
In particular, to make an explanation.
However, the main purpose of the book is to fully demonstrate the charm of Python 3.4, so I do not
It will word to show how the code in this book works in the old version. In this book, The big
Most examples are slightly modified (not even modified) to run in Python 2.7.
But there are some examples where a lot of rewriting is required if backward compatibility is pursued.
That being said, I still think that even if you can't get away from Python 2.7, this book will
Very helpful, because the core concept of Pyhon language will not change. Python 3 also does not
is a brand new language, most of the changes will probably be able to adapt in the afternoon, official documents
The "new features of Python 3.0" section
( is a good entry point. Solid
However, since 2009, Python 3.0 has changed, but these changes are
The difference between Python 3.0 and Python 2.0 is not so important.
If you are not sure if your familiarity with Python can keep up with the contents of this book, it is recommended
You look back at the official Python tutorials. Note that unless a new feature with Python 3 is
The rest of the tutorial, the book will not be repeated.
non-target readers
If you have just begun to learn Python, the content of this book may appear to be "hyper-dimensional". than difficult
To make it worse, if you are prematurely exposed to the contents of the book while learning Python, you may
Would mistakenly assume that all Python code should take advantage of special methods and meta-programming
(metaprogramming) skills. We know that immature abstraction and premature optimization of one
Like, it will be bad.
The structure of the book
If you are the target reader of this book, you should be able to read it from any chapter of this book,
But if you follow my idea of writing, the book is divided into six separate parts,
Chapters within each section are best read in order.
Before you introduce a way to implement some of your own functionality, I'll usually start with a ready-to-use
Clearly. For example, the 2nd chapter of the second part covers the sequence type (sequence
Type), but a class like collections.deque may be around. Always
In part four, we'll see how to get from abstract base class,
ABC), the abstract base class is encapsulated in the COLLECTIONS.ABC package. Such as
If you want to create your own ABC, you may have to see the last of the four parts.
Because I have always felt that without the proficiency of ABC experience, rushed to achieve a set of self-
It is not appropriate to own something.
There are several benefits to doing so. First, knowing what tools are readily available to avoid re-sending
Bright wheels. After all, the probability that we use an existing collection type (collection type) is much larger than
Write a new set of your own hands. Second, in this way, before discussing how to write a new type, I
can have more opportunities to understand the advanced usage of these ready-made classes. Third, compared to the zero
It should be simpler to build an ABC and inherit the existing ABC library. Finally, I think
Once you've seen some real-world cases, it's easier to understand abstractions.
Of course, this will also bring some inconvenience, such as the book's forward reference will be scattered in the
A different chapter inside. But after this sort of comb, I think the inconvenience is also
Can tolerate.
The following is the subject of each part of the book
The first part
The first section has a separate chapter that explains the Python data model
Model), and how to use special methods to ensure consistent behavior (such as
__REPR__), after all, Python's consistency is famous. In fact, the whole book is almost always
In explaining the Python data model, the 1th chapter is an overview.
Part II
The second part contains the various collection types: sequence (sequence), mapping
(mapping) and set (set), plus a reference to the string (str) and byte sequences
(bytes) distinction. Speaking of which, the last point is to let the Pro (Python 3 users)
Fast, xenophobic (Python 2 users) a key to the pain, because this distinction causes Python 2
The difficulty of migrating code to Python 3 is steep. The second part of the goal is to help readers recall
Python's built-in class library, incidentally, explains some of the less intuitive areas of these class libraries. Specific to
Examples have Python 3 how to reorder dict keys where we can't see them, or
is a matter of note when sorting strings that have a region (locale) dependency. In order to achieve this part
Some of the chatty, such as sequence type and mapping type
That's the way it is, sometimes it's written in depth, for example, I'm going to dict and set the bottom
The hash table for a deeper discussion.
Part III
How to use a function as a class object (First-order objects). The third part of the first
It will explain what the previous sentence means, and then the topic extends to the notion that it is widely
The impact of the design model of the pan use, and finally the reader will see how to use the closure (closure)
Concept to implement a function adorner (functions decorator). This part of the topic also includes
These basic concepts of Python: callable (callable), function properties (functions
attribute), introspection (introspection), parameter annotations (parameter annotation), and
A new nonlocal statement in Python 3.
Fourth part
Here, the focus of the book shifts to the construction of the class. Although in the second part of the
In the example, the class declaration appears, but the fourth chapter presents a more
Multi-class. Like any object-oriented language, Python has its own features, which
Sex may not appear in the language where you and I are learning class-based programming. Chapter of this section
Explains the principle of reference (reference), the concept of "variability", the life cycle of an instance,
How to build a custom collection type and ABC, multiple inheritance How to straighten out, when
Operator overloading and its methods should be used.
Fifth part
Some of the structures and libraries in Python are no longer content with conditional judgments, loops, and subroutines
(subroutine) such as sequential control processes, the text of part five will focus on these constructs
and the library. We will start with the generator (generator) and the topic will be transferred to the context
Manager (context Manager) and co-coroutine, which will cover the new features
Strong but not easy to understand yield from syntax. This is part of the concurrency and
I/O to the end, which is related to concurrency is collections.futures this
A very new package that encapsulates the concept of threads and processes with the help of the futures package;
Related to event-oriented I/O is the Asyncio, which is based on the co-process and yield
From the futures package.
Sixth part
The beginning of part six describes how to dynamically create classes with attributes to handle things such as
Semi-structured data such as JSON. And then from the features that you are already familiar with (property)
mechanism, using descriptors to interpret the access of Python object properties from the underlying. Meanwhile, the letter
The relationship between the number, the method, and the descriptor will also be combed over. The sixth chapter realizes from beginning to finish
A field validator, and in this process we will encounter some subtle problems, and then in the most
In the latter chapter, the natural derivation of the class decorator and meta-class (Metaclass)
These high-level concepts.
On the basis of practice
In general, we use the interactive console of Python to explore a variety of libraries and languages
Body Some readers may be more familiar with static languages that need to be compiled, but these languages may
REPL (Read-eval-print Loop, read, evaluate, and output loops) are not provided. In
Here I would like to highlight the Python Interactive console, also known as REPL, as a learning
The importance of the tool.
Doctest ( is a standard Python
Quasi-Library, for testing purposes. This library verifies that an expression evaluates by simulating the console dialog
Correct, and the test of almost all the code in this book, including those that are in the console,
is done through this library. Doctest looks like a play on the Python Interactive console
Ben, you don't even need to know the mechanics behind it, and you can use it directly to test the book.
For example.
I sometimes want to explain the purpose of a piece of code before showing the code before the corresponding
Doctest text. This is because I think that before considering how to implement a function, the first strict
To list what this feature can do, which can help us to spend our time in programming
Party. The essence of test-driven development (TDD) is to write tests first, and I later find this spirit
It is also of great benefit in teaching. If you're not familiar with doctest, take some time to read
Its documentation ( Combining the source of this book
In the console, type python3-m doctest to verify the book.
The correctness of almost all code in the
There are some simple times and benchmarks in the book, and when I run these tests, I write books.
Of the two laptop computers. One MacBook Pro 13-inch note, produced in 2011
2.7 GHz Intel Core i7 processor, 8GB memory, and mechanical hard
The other is a MacBook Air 13-inch notebook produced in 2014, configured to be 1.4
GHz Intel Core i5 processor, 4GB memory, and a solid-state drive. MacBook Air
The processor is slower, the memory is not more than the other, but its memory is faster
(Mhz,macbook Pro 13 inches is 1333 MHz), and its hard drive also
Faster, so in everyday use I don't feel the difference in speed between the two notebooks.
Remarks: A personal point of view
Since 1998, I have been using Python, as well as Python teaching, and have been
to defend it. I've always enjoyed the process, especially when I like to study Python and other language
The difference between design and theory. So at the end of some chapters, I'll add a little bit of myself
As for Python and other languages, I called this Part "talk." If you're on these
Things are not interesting, skip can, because these are not required to read.

1th Python Data Model

2nd array of sequence composition

3rd Chapter Dictionaries and collections

4th chapter text and byte sequences

5th Chapter-Class function

The 6th chapter uses the class function to realize the design model

7th Chapter function Decorators and closures

Chapter 8th object references, variability, and garbage

9th Python-style objects

The 10th chapter modifies, hashes and cuts the sequence

Chapter 11th Interface: From protocol to abstract base

Chapter 12th Inheritance Advantages and disadvantages

13th correct overloaded operators

14th iteration of an object, iterator
Kazuo Generator

Chapter 15th Context Manager and Else block

16th Chapter Co-process

The 17th chapter of the use of material processing concurrency

The 18th Chapter uses Asyncio package processing and

19th Dynamic properties and features

20th attribute Descriptor

The 21st chapter of Class meta-programming

Smooth python PDF download HD full scan original

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: 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.