Table Of Contentptg21061391
Musée d’Orsay, Paris, France
Located on the Seine’s left bank, the Musée d’Orsay
is housed in a breathtaking Beaux-Arts building originally
designed as the world’s first electrified urban railway ptg21061391
station. The original “Gare d’Orsay” was built on the
site of the old Palais d’Orsay, which had lain empty
since it burned in 1871 during the Paris Commune.
The building opened on Bastille Day, July 14, 1900,
to help celebrate Paris’s Fifth Universal Exhibition.
Designated a Historical Monument in 1978, it was
then recreated as a museum by Renaud Bardon,
Pierre Colboc, and Jean-Paul Philippon of the ACT
architecture group. Per the museum’s official history,
the new architects “highlighted the great hall, using
it as the main artery of the visit, and transformed
the magnificent glass awning into the museum’s
entrance.” Inside, Gae Aulenti adapted the enormous
station into museum spaces, unified via consistent
stone wall and floor surfaces. Opened in 1986,
the new museum brought together three major
art collections from the era 1848-1914. More than
three million visitors now come every year to see
works from artists including Cézanne, Courbet,
Degas, Gauguin, Manet, Monet, and Renoir.
The Python 3
Standard Library
by Example
ptg21061391
Developer’s Library
Visit informit.com/devlibrary for a complete list of available publications.
The Developer’s Library series from Addison-Wesley provides practicing ptg21061391
programmers with unique, high-quality references and tutorials on the latest
programming languages and technologies they use in their daily work. All
books in the Developer’s Library are written by expert technology practioners
who are exceptionally skilled at organizing and presenting information in a
way that is useful for other programmers.
Developer’s Library titles cover a wide range of topics, from open source
programming languages and technologies, mobile application development,
and web development to Java programming and more.
The Python 3
Standard Library
by Example
ptg21061391
Doug Hellmann
Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town
Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City
São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
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 the publisher was aware of a trademark
claim,thedesignationshavebeenprintedwithinitialcapitallettersorinallcapitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or ptg21061391
impliedwarrantyofanykindand assumenoresponsibilityforerrorsoromissions.Noliabilityisassumed
for incidental or consequential damages in connection with or arising out of the use of the information or
programscontainedherein.
For information about buying this title in bulk quantities, or for special sales opportunities (which
may include electronic versions; custom cover designs; and content particular to your business, train-
ing goals, marketing focus, or branding interests), please contact our corporate sales department at
[email protected](800)382-3419.
Forgovernmentsalesinquiries,[email protected].
ForquestionsaboutsalesoutsidetheU.S.,[email protected].
VisitusontheWeb:informit.com/aw
LibraryofCongressControlNumber:2017932317
Copyright©2017PearsonEducation,Inc.
Allrightsreserved.PrintedintheUnitedStatesofAmerica.Thispublicationisprotectedbycopyright,and
permissionmustbeobtainedfromthepublisherpriortoanyprohibitedreproduction,storageinaretrieval
system,ortransmissioninanyformorbyanymeans,electronic,mechanical,photocopying,recording,orlike-
wise.Forinformationregardingpermissions,requestformsandtheappropriatecontactswithinthePearson
EducationGlobalRights&PermissionsDepartment,pleasevisitwww.pearsoned.com/permissions/.
ISBN-13:978-0-13-429105-5
ISBN-10:0-13-429105-0
1 17
For Theresa,
my one true love.
ptg21061391
This page intentionally left blank
ptg21061391
Contents at a Glance
Introduction xxxi
Acknowledgments xxxiii
About the Author xxxv
Chapter 1 Text 1
Chapter 2 Data Structures 65
Chapter 3 Algorithms 143
Chapter 4 Dates and Times 211
Chapter 5 Mathematics 239
ptg21061391
Chapter 6 The File System 295
Chapter 7 Data Persistence and Exchange 395
Chapter 8 Data Compression and Archiving 477
Chapter 9 Cryptography 523
Chapter 10 Concurrency with Processes, Threads, and Coroutines 535
Chapter 11 Networking 687
Chapter 12 The Internet 753
Chapter 13 Email 841
Chapter 14 Application Building Blocks 887
Chapter 15 Internationalization and Localization 1003
Chapter 16 Developer Tools 1023
Chapter 17 Runtime Features 1169
Chapter 18 Language Tools 1279
vii
viii Contents at a Glance
Chapter 19 Modules and Packages 1329
Appendix A Porting Notes 1351
Appendix B Outside of the Standard Library 1367
Index of Python Modules 1373
Index 1375
ptg21061391