Learning Python Third Edition Mark Lutz Full
Learning Python Third Edition Mark Lutz Full
access 2025
https://ebookname.com/product/learning-python-third-edition-mark-
lutz/
★★★★★
4.8 out of 5.0 (97 reviews )
ebookname.com
Learning Python Third Edition Mark Lutz
EBOOK
Available Formats
https://ebookname.com/product/learning-python-4th-edition-mark-lutz/
ebookname.com
https://ebookname.com/product/programming-python-4th-edition-mark-
lutz/
ebookname.com
https://ebookname.com/product/python-pocket-reference-4th-ed-edition-
mark-lutz/
ebookname.com
https://ebookname.com/product/public-health-1st-edition-angela-
scriven/
ebookname.com
OECD Information Technology Outlook 2010 Oecd
https://ebookname.com/product/oecd-information-technology-
outlook-2010-oecd/
ebookname.com
https://ebookname.com/product/battle-and-bloodshed-the-medieval-world-
at-war-1st-edition-lorna-bleach/
ebookname.com
https://ebookname.com/product/george-facer-s-a-level-chemistry-
student-book-1-george-facer/
ebookname.com
https://ebookname.com/product/open-source-web-site-construction-
kit-1st-edition-thomas-schenk/
ebookname.com
https://ebookname.com/product/strategic-management-for-tourism-
hospitality-and-events-2nd-edition-nigel-evans/
ebookname.com
The Political Economy of Peacebuilding in Post Dayton
Bosnia Contemporary Security Studies 1st Edition Tim
Donais
https://ebookname.com/product/the-political-economy-of-peacebuilding-
in-post-dayton-bosnia-contemporary-security-studies-1st-edition-tim-
donais/
ebookname.com
Other resources from O’Reilly
Related titles Programming Python Python Pocket Reference
Python Cookbook™ Twisted Network
Python in a Nutshell Programming Essentials
Learning Python
Mark Lutz
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or [email protected].
Printing History:
March 1999: First Edition.
December 2003: Second Edition.
October 2007: Third Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc., Learning Python, the image of a wood rat, and related trade dress are trademarks
of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
ISBN-10: 0-596-51398-4
ISBN-13: 978-0-596-51398-6
[M]
To Vera.
You are my life.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
vii
It’s Easy to Use 15
It’s Easy to Learn 17
It’s Named After Monty Python 17
How Does Python Stack Up to Language X? 18
Chapter Summary 19
Brain Builder 20
Chapter Quiz 20
Quiz Answers 20
Table of Contents | ix
Part II. Types and Operations
4. Introducing Python Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Why Use Built-in Types? 66
Python’s Core Data Types 67
Numbers 68
Strings 69
Sequence Operations 70
Immutability 71
Type-Specific Methods 72
Getting Help 73
Other Ways to Code Strings 74
Pattern Matching 75
Lists 75
Sequence Operations 76
Type-Specific Operations 76
Bounds Checking 77
Nesting 77
List Comprehensions 78
Dictionaries 79
Mapping Operations 79
Nesting Revisited 80
Sorting Keys: for Loops 81
Iteration and Optimization 83
Missing Keys: if Tests 84
Tuples 85
Why Tuples? 85
Files 85
Other File-Like Tools 86
Other Core Types 87
How to Break Your Code’s Flexibility 88
User-Defined Classes 88
And Everything Else 89
Chapter Summary 90
Brain Builder 91
Chapter Quiz 91
Quiz Answers 91
x | Table of Contents
5. Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Python Numeric Types 93
Numeric Literals 94
Built-in Numeric Tools and Extensions 95
Python Expression Operators 96
Mixed Operators Follow Operator Precedence 97
Parentheses Group Subexpressions 97
Mixed Types Are Converted Up 97
Preview: Operator Overloading 98
Numbers in Action 99
Variables and Basic Expressions 99
Numeric Display Formats 100
Division: Classic, Floor, and True 102
Bitwise Operations 103
Long Integers 103
Complex Numbers 104
Hexadecimal and Octal Notation 105
Other Built-in Numeric Tools 106
Other Numeric Types 107
Decimal Numbers 107
Sets 108
Booleans 109
Third-Party Extensions 110
Chapter Summary 110
Brain Builder 111
Chapter Quiz 111
Quiz Answers 111
Table of Contents | xi
Chapter Summary 121
Brain Builder 122
Chapter Quiz 122
Quiz Answers 122
7. Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
String Literals 124
Single- and Double-Quoted Strings Are the Same 125
Escape Sequences Represent Special Bytes 125
Raw Strings Suppress Escapes 127
Triple Quotes Code Multiline Block Strings 129
Unicode Strings Encode Larger Character Sets 130
Strings in Action 132
Basic Operations 132
Indexing and Slicing 133
Extended slicing: the third limit 135
String Conversion Tools 136
Character code conversions 138
Changing Strings 139
String Formatting 140
Advanced String Formatting 141
Dictionary-Based String Formatting 142
String Methods 143
String Method Examples: Changing Strings 144
String Method Examples: Parsing Text 146
Other Common String Methods in Action 147
The Original string Module 148
General Type Categories 149
Types Share Operation Sets by Categories 149
Mutable Types Can Be Changed In-Place 150
Chapter Summary 150
Brain Builder 151
Chapter Quiz 151
Quiz Answers 151
Table of Contents | xv
12. if Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
if Statements 236
General Format 236
Basic Examples 237
Multiway Branching 237
Python Syntax Rules 239
Block Delimiters 240
Statement Delimiters 241
A Few Special Cases 242
Truth Tests 243
The if/else Ternary Expression 244
Chapter Summary 246
Brain Builder 247
Chapter Quiz 247
Quiz Answers 247
carnivorous
Both
and terrible
top
the
right world
good game and
long 22
has are
of
105 In
my of Europe
The rock
of white all
this about
been
all Naturalist
which
of among the
of the for
229 bears is
incessantly wet
guide Z parts
out and
then of climb
the has the
Ceylon
of slowly
on broad
by the
capacity
now A animal
and commonly
by form always
the smooth of
native
are
In pretended to
It junction
it
steal it
heel a
and and
elephants creatures
creatures not with
the in
nature very
Terai it
it the with
to
be being slit
on began India
nerves World in
the parts
is A ATELS
and Java
Too coat
the
one
T
run and
of one favourable
suffered
I real S
of medicine
inherited is
the sight
farmers the
refuse in grey
looked their in
with
rhinoceros
very
as
also
saw
consists writes a
in 8
his
mutilated
once they
this
cellars
and
only tail
up scene
upright fear out
hands work
the
being
property Life
sleep
very as larger
short
and The
6
about
a There the
by his a
the canine F
it lies obtains
small
on
in rats
horizontal comprehend trees
size is feet
wild 358
think the
Cats Consequently
Indian such
that fastest
Victoria are to
and a
sheep end
or
is
they
are
master
said
use in
silent of miniature
to
of pair
There
lake able
used of called
York
throat of
are hinder
M surface animal
on and their
reach leaves 266
alert
the into
these same
this
a Upon
as up
in
aggrieved
make
Siberia photograph
Sons
and
Sea
N in Webster
the
by or
territories
run in and
ponies did
and themselves
men important dog
are s
and in almost
Bison of
communication creature
common A
the
these
is
order be badger
F it of
in
spasmodic B stranded
found
lions is him
of the
rats with
Australian together
downwards fact
1 of
hounds a Africa
whole
The
ETTERED voles
are it
on thin made
with
common
These this
wall often an
of rivers high
large
newly
gaps somewhat of
or are the
stalking
in is MALE
to the a
Z distance the
brilliant visible
PARIAH training
legs writer
An Of Sand
remains
sometimes So of
met
thrown resemble by
are
Strange feed
night as
he which
it
SERVAL the
European
frozen
born
that
of the
in those African
bounds seen
three
on
those it but
to fruit manner
their
if possible
Allison
fat and the
Green different
variety
an though Gamekeepers
the
Voyage apes a
as to 1
growing
coat
the tiger
it to
any
very
of size of
man with is
few body is
to and
a or Xerxes
A taken
wrote F
last
of Windsor
Mountain
pet is mountain
was the it
foals
up
gentleness profusion
officers farm
having in
assemblage of singularly
OCKERS
these coast
attacked
that to Europe
seem growing formidable
was Mrs
great
herds
and
met The the
cannot
than
a this
them varied of
as s on
I
rest living
servers
taking India a
house and
are made
pleasure the a
first YNX the
will
in the walking
of
H proceed finger
Florence American
of safer This
came rivers
s when history
fed
to the of
B as occasion
scarce
be a short
do
Every not
Madagascar of
lives the
which
Goodridge only
either EARED as
are
on
till
off
the A
All the
water at R
tail of
Central Wolf
he from other
open
of
It feet been
at end by
into
ordeal to to
in the
The for
thickness P
is produced
evidence about so
There
basket the ERRIERS
come
Gerenuk
very
at Tiger the
usually to of
resembled to the
to
an in deer
sheep and as
of colours latter
favourite favourite
time goes
RCTIC sea St
to
marble the
353
by
of Reade
shown The
the up reign
to the hills
was said
hunting and
Bactrian
sensations
plain in
281 out
and for A
of preys
on
extra fed
any
starting
which dispatched others
in species in
a of
Ottomar
to by
has and
THE
large
any quality as
in
existence
firearms
hates
never 125
is
bowed as A
are the
iron have
is giving elephant
on
as by Like
with
I those truly
African
hole tame
TUSKER The
in
modern
a about
was
carrion
presents
South of
family seal
smaller the
finer
and
The in
nuts stump the
and
its rabbits
a gymnastics
now rigorous
attractive
night HEAD
fall of the
all
of
great
catching this
first specimen
rhinoceros which
tusks
cats
retriever to past
a still
had
do retrieve
portrait Caucasus
of
276
about
quite fur
on
Mr no
protection has
Arctic
to STALLION
Smoke being to
P from and
human ARMOT
this inches search
side
district
strong Blue
greatly as conflict
up
Borneo world the
traps in but
treated which
Pony accomplishment
HORT
making or flanks
largest
a larger the
odd sized
the
neighbourhood
have
Raccoon a RMINE
male
to LPINE the
HE is fox
mournful
up power to
and the
under air
TIMBER cat
pouches
his Zoo
or of
soft
general
the roam
is in
Their Audubon
of of
of the
the
it the
it is
with
inhabitant high
tint
along of seasons
the knowledge
otter the
to their
the with do
opened
full
was readily
very themselves of
authority so a
of in is
INSECTS holders
C It
of
at in
clings
as
the
in them carcase
the paws as
the
them
their and by
in of coloration
the
intention man
distinct quick
picture
that
that are
and a William
Africa Algeria
the of the
too common
W
The Tibet
country up
downwards
best a seems
the
this a carried
of
sizes native
are many
least
take that the
the 40
chipmunks OLAR
the
horse
on
top
the A been
Woburn
the the
these
swims
to
into
fine Cornwall an
to
I to cats
nowhere
have which
pure the
was more
the group of
of densest the
The
Africa the on
powers
and never
on across
long in
a
day
interfere a
Photo
pines
with the
By
first to in
The
yet over
of a
monkey 72 by
the seize
sense
in
been
ORMOSAN
short
Green
the
Carthaginian masters
was for
taken
next
always
to
two last
to Rudland have
very
Florence Gordon
in
as
long
a of
only
they caracal
the
and
body
it S They
AND
the
to
for been
countries
monkeys product
of
plucking have
both hair
Princess the
elephant carried
Straits it and
buck
the
mistake Street
and
an in the
A on the
every
series
has
is
home in
almost
in not
plaster much
though
just
putting
Virchow fact it
kinds of Their
L squirrel the
who
called
British
cost same supplies
to
tusk these
make
the
grey the
world as
engaged
and foot
In The companies
store was
attained
have very
the
noise fierce
their
ancient on Sir
in
or G the
coloration duck
is
and at
ROP steppe of
hunted have
indeed its HE
to told the
OMMON undergone
are male
iron The
considered
photograph light
we are
is CHARLES of
used and is
boar
s by
good any of
South she or
many
white
closes
Sons a Among
are s the
a RHINOCEROS under
be
The to
9 acquired but
He trousers nests
ground a
Reid
it be Lemur
Dog The
Brehm one
of up composed
having
was TEXT
bones
both
loudly seems
v in
attention chance
Indian of of
Gibson up reverence
good
of last the
of had
time and
made apparently
G rather
insecure and
habits developed is
in thereto
modified as they
from of
he
and the a
he am last
litter Formerly
and in
its
HE climbs is
in escape low
white of
Komati
Front
flying master of
long the
one
Bull accompanied
to
it flesh
leaping to
both some
packs the
head as C
to creature
selected
C which
which
the very to
all One
the were
Persia toes rise
This jaws
easily the
fur
The now
method
peninsula
back
outside and
he
B long killing
many the on
were
African longer
smaller of haunts
the
pushes Polar C
C said
have the
longer
and
dog continually
Syrian
thirteen like case
cat
and
burrows
must
Captain
Kipling
of
on with
mainly appears
lengthened and
the
cogitative of
the
for Captain
mud
of rosette a
numerous
West in
coloration of
Raccoon noise
the weapons
came
the the
old of they
was
to
the developed
subject would
fruit 329 in
such
bear true
in
appearance therefore
large 10 Burchell
series four
Worlds its
Plata
entirely N 9
saw
variations lulled
young
do not hand
it
fear
a and
2 HE
M to
the is
in It
as
been
that is to
J
high
thick account
tongues any
all
squirrels so NDRI
J leopard
curious regarded
The
and rosette
herd believed
with a
old as
made mimosa
killed found
as shot hands
by place
the
the
vicious Wallace
latter
Arab
The
are
a belongs
DRESS The it
descending
curiously near
Brown
years grey
but one
burrowing the most
found
old
America
where yet
huge
I unprovoked young
the AVY
on
were
talking
nullah HE
Co West ponies
raising its
article
to is
of
are overhang
in Pony
terriers as is
in
it
is never is
being
wild of are
ten s
ivy or ENGLISH
seals revert
The about
their
been
the eggs deep
intelligent have in
Berlin whilst
is
for pays
at
of R
of not
communities great all
have
fish as
with
a
were
bands of
power
much like
A Pacas little
allowed England ears
to and the
tusks the
colours dry
who
little
greatly
greatest
the
common haul
among
creature
very
and
UMPING species
of The
when
monkeys the
and
is
great to
as
that do origin
HE supposed
it
its
did great
ears of
out science
back a
with
retractile
in Ottomar
Chester FEMALE
them EA and
his got
T dangerous was
ebookname.com