Fluent Python

Fluent Python

Luciano Ramalho

Language: English

Pages: 792

ISBN: 1491946008

Format: PDF / Kindle (mobi) / ePub

Fluent Python

Luciano Ramalho

Language: English

Pages: 792

ISBN: 1491946008

Format: PDF / Kindle (mobi) / ePub


Python’s simplicity lets you become productive quickly, but this often means you aren’t using everything it has to offer. With this hands-on guide, you’ll learn how to write effective, idiomatic Python code by leveraging its best—and possibly most neglected—features. Author Luciano Ramalho takes you through Python’s core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time.

Many experienced programmers try to bend Python to fit patterns they learned from other languages, and never discover Python features outside of their experience. With this book, those Python programmers will thoroughly learn how to become proficient in Python 3.

This book covers:

  • Python data model: understand how special methods are the key to the consistent behavior of objects
  • Data structures: take full advantage of built-in types, and understand the text vs bytes duality in the Unicode age
  • Functions as objects: view Python functions as first-class objects, and understand how this affects popular design patterns
  • Object-oriented idioms: build classes by learning about references, mutability, interfaces, operator overloading, and multiple inheritance
  • Control flow: leverage context managers, generators, coroutines, and concurrency with the concurrent.futures and asyncio packages
  • Metaprogramming: understand how properties, attribute descriptors, class decorators, and metaclasses work

Perl Power!: The Comprehensive Guide

Application Development with Swift

PHP & MySQL: Novice to Ninja

Ansible: Up and Running

Node.js Recipes: A Problem-Solution Approach

 

 

 

 

 

 

 

 

 

 

 

 

 

['raspberry', 'banana', 'grape', 'apple'] >>> fruits ['grape', 'raspberry', 'apple', 'banana'] >>> fruits.sort() >>> fruits ['apple', 'banana', 'grape', 'raspberry'] This produces a new list of strings sorted alphabetically. Inspecting the original list, we see it is unchanged. This is simply reverse alphabetical ordering. A new list of strings, now sorted by length. Because the sorting algorithm is stable, “grape” and “apple,” both of length 5, are in the original order. These are the strings

['raspberry', 'banana', 'grape', 'apple'] >>> fruits ['grape', 'raspberry', 'apple', 'banana'] >>> fruits.sort() >>> fruits ['apple', 'banana', 'grape', 'raspberry'] This produces a new list of strings sorted alphabetically. Inspecting the original list, we see it is unchanged. This is simply reverse alphabetical ordering. A new list of strings, now sorted by length. Because the sorting algorithm is stable, “grape” and “apple,” both of length 5, are in the original order. These are the strings

str.upper, just passing a reference to that method so the sorted function can use it to normalize the words for sorting.2 Example 3-3. Partial output from Example 3-2 processing the Zen of Python; each line shows a word and a list of occurrences coded as pairs: (line-number, column-number) $ python3 index0.py ../../data/zen.txt a [(19, 48), (20, 53)] Although [(11, 1), (16, 1), (18, 1)] ambiguity [(14, 16)] and [(15, 23)] are [(21, 12)] aren [(10, 15)] at [(16, 38)] bad [(19, 50)] be [(15, 14),

design: beautiful, simple, and clear. Guido van Rossum, son of an architect and brother of a master font designer, created a masterpiece of language design. I love teaching Python because it is beautiful, simple, and clear. Alex Martelli and Anna Ravenscroft were the first people to see the outline of this book and encouraged me to submit it to O’Reilly for publication. Their books taught me idiomatic Python and are models of clarity, accuracy, and depth in technical writing. Alex’s 5,000+ Stack

Overflow posts are a fountain of insights about the language and its proper use. Martelli and Ravenscroft were also technical reviewers of this book, along with Lennart Regebro and Leonardo Rochael. Everyone in this outstanding technical review team has at least 15 years of Python experience, with many contributions to high-impact Python projects in close contact with other developers in the community. Together they sent me hundreds of corrections, suggestions, questions, and opinions, adding

Download sample

Download