Python Essentials
eBook - ePub

Python Essentials

Steven F. Lott

Partager le livre
  1. 298 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Python Essentials

Steven F. Lott

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Python Essentials est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Python Essentials par Steven F. Lott en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Programmierung. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2015
ISBN
9781784390341
Édition
1
Sous-sujet
Programmierung

Python Essentials


Table of Contents

Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started
Installation or upgrade
Installing Python on Windows
Considering some alternatives
Upgrading to Python 3.4 in Mac OS X
Adding the Tkinter package
Upgrading to Python 3.4 in Linux
Using the Read-Evaluate-Print Loop (REPL)
Confirming that things are working
Doing simple arithmetic
Assigning results to variables
Using import to add features
Interacting with the help subsystem
Using the pydoc program
Creating simple script files
Simplified syntax rules
The Python ecosystem
The idea of extensibility via add-ons
Using the Python Package Index – PyPI
Using pip to gather modules
Using easy_install to add modules
Installing modules manually
Looking at other Python interpreters
Summary
2. Simple Data Types
Introducing the built-in operators
Making comparisons
Using integers
Using the bit-oriented operators
Using rational numbers
Using decimal numbers
Using floating-point numbers
Using complex numbers
The numeric tower
The math libraries
Using bits and Boolean values
Working with sequences
Slicing and dicing a sequence
Using string and bytes values
Writing string literals
Using raw string literals
Using byte string literals
Using the string operators
Converting between Unicode and bytes
Using string methods
Accessing the details of a string
Parsing strings into substrings
Using the tuple collection
The None object
The consequences of immutability
Using the built-in conversion functions
Summary
3. Expressions and Output
Expressions, operators, and data types
Using operators on non-numeric data
The print() function
Examining syntax rules
Splitting, partitioning, and joining strings
Using the format() method to make more readable output
Summary of the standard string libraries
Using the re module to parse strings
Using regular expressions
Creating a regular expression string
Working with Unicode, ASCII, and bytes
Using the locale module for personalization
Summary
4. Variables, Assignment and Scoping Rules
Simple assignment and variables
Multiple assignment
Using repeated assignment
Using the head, *tail assignment
Augmented assignment
The input() function
Python language concepts
Object types versus variable declarations
Avoiding confusion when naming variables
Garbage collection via reference counting
The little-used del statement
The Python namespace concept
Globals and locals
Summary
5. Logic, Comparisons, and Conditions
Boolean data and the bool() function
Comparison operators
Combining comparisons to simplify the logic
Testing float values
Comparing object IDs with the is operator
Equality and object hash values
Logic operators – and, or, not, if-else
Short-circuit (or non-strict) evaluation
The if-elif-else statement
Adding elif clauses
The pass statement as a placeholder
The assert statement
The logic of the None object
Summary
6. More Complex Data Types
The mutability and immutability distinction
Using the list collection
Using list operators
Mutating a list with subscripts
Mutating a list with method functions
Accessing a list
Using collection functions
Using the set collection
Using set operators
Mutating a set with method functions
Using augmented assignment with sets
Accessing a set with operators and method functions
Mappings
Using dictionary operators
Using dictionary mutators
Using methods for accessing items in a mapping
Using extensions from the collections module
Processing collections with the for statement
Using literal lists in a for statement
Using the range() and enumerate() functions
Iterating with the while statement
The continue and break statements
Breaking early from a loop
Using the else clause on a loop
Summary
7. Basic Function Definitions
Looking at the five kinds of callables
Defining functions with positional parameters
Defining multiple parameters
Using the return statement
Evaluating a function with positional or keyword arguments
Writing a function's docstring
Mutable and immutable argument values
Defining optional parameters via default values
A warning about mutable default values
Using the "everything else" notations of * and **
Using sequences and dictionaries to fill in *args and *kw
Nested function definitions
Working with namespaces
Assigning a global variable
Assigning a non-local variable
Defining lambdas
Writing additional function annotations
Summary
8. More Advanced Functions
Using the for statement with iterable collections
Iterators and iterable collections
Consequences and next steps
Using generator expressions and comprehensions
Limitations of generator expressions
Using multiple loops and conditions
Writing comprehensions
Defining generator functions with the yield statement
Using the higher-order functions
Writing our own higher-order functions
Using the built-in reductions – max, min, and reduce
Three ways to sort a sequence
Sorting via a key function
Sorting via wrapping and unwrapping
Functional programming design patterns
Summary
9. Exceptions
The core exception concept
Examining the exception object
Using the try and except statements
Using nested try statements
Matching exception classes in an except clause
Matching more general exceptions
The empty except clause
Creating our own exceptions
Using a finally clause
Use cases for exceptions
Issuing warnings instead of exceptions
Permission versus forgiveness – a Pythonic approach
Summary
10. Files, Databases, Networks, and Contexts
The essential file concept
Opening text files
Filtering text lines
Working with raw bytes
Using file-like objects
Using a context manager via the with statement
Closing file-like objects with contextlib
Using the shelve module as a database
Using the sqlite database
Using object-relational mapping
Web services and Internet protocols
Physical format considerations
Summary
11. Class Definitions
Creating a class
Writing the suite of statements in a class
Using instance variables and methods
Pythonic object-oriented programming
Trying to do type casting
Designing for encapsulation and privacy
Using properties
Using inheritance to simplify class definitions
Using multiple inheritance and the mixin...

Table des matiĂšres