The Quick Python Book, Second Edition - Shen@uiuc

1y ago
64 Views
9 Downloads
5.93 MB
362 Pages
Last View : Today
Last Download : 3m ago
Upload by : Hayden Brunner
Transcription

SECOND EDITIONSECOND EDITIONCovers Python 3First edition by Daryl K. HarmsKenneth M. McDonaldNaomi R. CederMANNING

The Quick Python BookSecond EditionLicensed to Jay Vee metacyclist@gmail.com

Licensed to Jay Vee metacyclist@gmail.com

The QuickPython BookSECOND EDITIONNAOMI R. CEDERFIRST EDITION BY DARYL K. HARMSKENNETH M. McDONALDMANNINGGreenwich(74 w. long.)Licensed to Jay Vee metacyclist@gmail.com

For online information and ordering of this and other Manning books, please visitwww.manning.com. The publisher offers discounts on this book when ordered in quantity.For more information, please contact:Special Sales DepartmentManning Publications Co.Sound View Court 3BGreenwich, CT 06830Email: orders@manning.com 2010 by Manning Publications Co. All rights reserved.No part of this publication may be reproduced, stored in a retrieval system, or transmitted, inany form or by means electronic, mechanical, photocopying, or otherwise, without prior writtenpermission of the publisher.Many of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks. Where those designations appear in the book, and ManningPublications was aware of a trademark claim, the designations have been printed in initial capsor all caps.Recognizing the importance of preserving what has been written, it is Manning’s policy to havethe books we publish printed on acid-free paper, and we exert our best efforts to that end.Recognizing also our responsibility to conserve the resources of our planet, Manning books areprinted on paper that is at least 15% recycled and processed without elemental chlorine.Manning Publications Co.Sound View Court 3BGreenwich, CT 06830Development editor:Copyeditor:Typesetter:Cover designer:Tara WalshLinda RecktenwaldMarija TudorLeslie HaimesCorrected printing, January 2013ISBN 9781935182207Printed in the United States of America1 2 3 4 5 6 7 8 9 10 – MAL – 15 14 13 12 11 10 09Licensed to Jay Vee metacyclist@gmail.com

brief contentsPART 1 STARTING OUT . 11 About Python32 Getting started3 The Quick Python overview1018PART 2 THE ESSENTIALS . 334 The absolute basics355 Lists, tuples, and sets6 Strings7 Dictionaries818 Control flow909 Functions10 Modules and scoping rules11 Python programs4563103115129vLicensed to Jay Vee metacyclist@gmail.com

viBRIEF CONTENTS12 Using the filesystem14713 Reading and writing files14 Exceptions15 Classes and object-oriented programming16 Graphical user interfaces159172186209PART 3 ADVANCED LANGUAGE FEATURES . 22317 Regular expressions22518 Packages19 Data types as objects20 Advanced object-oriented features234242247PART 4 WHERE CAN YOU GO FROM HERE? . 26321 Testing your code made easy(-er) 26522 Moving from Python 2 to Python 3 27423 Using Python libraries24 Network, web, and database programming 290282Licensed to Jay Vee metacyclist@gmail.com

contentspreface xviiacknowledgments xviiiabout this book xxPART 1 STARTING OUT . 11About Python 31.11.2Why should I use Python? 3What Python does well 4Python is easy to use 4 Python is expressive 4Python is readable 5 Python is complete—“batteriesincluded” 6 Python is cross-platform 6 Python is free 6 1.3 What Python doesn’t do as well 7Python is not the fastest language 7 Python doesn’t have themost libraries 8 Python doesn’t check variable types atcompile time 8 1.41.5Why learn Python 3?Summary 98viiLicensed to Jay Vee metacyclist@gmail.com

viiiCONTENTS2Getting started 102.12.2Installing Python 10IDLE and the basic interactive mode12The basic interactive mode 12 The IDLE integrated developmentenvironment 13 Choosing between basic interactive mode andIDLE 14 2.32.42.52.63Using IDLE’s Python Shell window 14Hello, world 15Using the interactive prompt to explore PythonSummary 1715The Quick Python overview 183.13.2Python synopsis 19Built-in data types 19Numbers 19 Lists 21 Tuples 22 Strings 23Dictionaries 24 Sets 24 File objects 25 3.3 Control flow structures25Boolean values and expressions 25 The if-elif-elsestatement 26 The while loop 26 The forloop 27 Function definition 27 Exceptions 28 3.43.53.6 Module creation 29Object-oriented programmingSummary 3130PART 2 THE ESSENTIALS . 334The absolute basics 354.14.24.34.44.54.6Indentation and block structuringDifferentiating comments 37Variables and assignments 37Expressions 38Strings 39Numbers 4035Built-in numeric functions 41 Advanced numericfunctions 41 Numeric computation 41 Complexnumbers 41 Advanced complex-number functions 42 4.7The None value43Licensed to Jay Vee metacyclist@gmail.com

ixCONTENTS4.84.94.104.115Getting input from the user 43Built-in operators 43Basic Python style 43Summary 44Lists, tuples, and sets 455.15.25.35.4Lists are like arrays 46List indices 46Modifying lists 48Sorting lists 50Custom sorting5.551 The sorted() functionOther common list operations5252List membership with the in operator 52 List concatenationwith the operator 53 List initialization with the *operator 53 List minimum or maximum with min andmax 53 List search with index 53 List matches withcount 54 Summary of list operations 54 5.65.7Nested lists and deep copiesTuples 5755Tuple basics 57 One-element tuples need acomma 58 Packing and unpacking tuples 58Converting between lists and tuples 60 5.8Sets60Set operations5.96Summary60 Frozensets6162Strings 636.16.26.3Strings as sequences of characters 63Basic string operations 64Special characters and escape sequences64Basic escape sequences 65 Numeric (octal and hexadecimal) andUnicode escape sequences 65 Printing vs. evaluating stringswith special characters 66 6.4String methods 67The split and join string methods 67 Converting strings tonumbers 68 Getting rid of extra whitespace 69 Stringsearching 70 Modifying strings 71 Modifying strings withlist manipulations 73 Useful methods and constants 73 Licensed to Jay Vee metacyclist@gmail.com

xCONTENTS6.56.6Converting from objects to stringsUsing the format method 7674The format method and positional parameters 76 The formatmethod and named parameters 76 Format specifiers 77 6.7Formatting strings with %Using formatting sequencesformatting sequences 786.86.977778 Named parameters andBytes 80Summary 80Dictionaries 817.1What is a dictionary?82Why dictionaries are called dictionaries 837.27.37.47.57.67.77.88Other dictionary operations 83Word counting 86What can be used as a key? 86Sparse matrices 88Dictionaries as caches 88Efficiency of dictionaries 89Summary 89Control flow 908.1The while loop90The break and continue statements8.28.3The if-elif-else statementThe for loop 929191The range function 93 Using break and continue in forloops 94 The for loop and tuple unpacking 94 Theenumerate function 94 The zip function 95 8.48.58.6List and dictionary comprehensions 95Statements, blocks, and indentation 96Boolean values and expressions 99Most Python objects can be used as Booleans 99Boolean operators 1008.78.8 Comparison andWriting a simple program to analyze a text file 101Summary 102Licensed to Jay Vee metacyclist@gmail.com

xiCONTENTS9Functions 1039.19.2Basic function definitions 103Function parameter options 105Positional parameters 105 Passing arguments by parametername 106 Variable numbers of arguments 107 Mixingargument-passing techniques 108 9.39.49.59.69.79.89.910 Mutable objects as arguments 108Local, nonlocal, and global variables 109Assigning functions to variables 111lambda expressions 111Generator functions 112Decorators 113Summary 114Modules and scoping rules 11510.110.210.310.4What is a module? 115A first module 116The import statement 119The module search path 119Where to place your own modules 12010.510.610.710.811Private names in modules 121Library and third-party modules 122Python scoping rules and namespaces 123Summary 128Python programs 12911.1Creating a very basic program130Starting a script from a command line 130 Command-linearguments 131 Redirecting the input and output of ascript 131 The optparse module 132 Using the fileinputmodule 133 11.211.311.4 Making a script directly executable on UNIXScripts on Mac OS X 135Script execution options in Windows 135135Starting a script as a document or shortcut 136 Starting a scriptfrom the Windows Run box 137 Starting a script from acommand window 137 Other Windows options 138 Licensed to Jay Vee metacyclist@gmail.com

xiiCONTENTS11.511.611.7Scripts on Windows vs. scripts on UNIXPrograms and modules 140Distributing Python applications 145distutils 145 py2exe and py2appprograms with freeze 145145 11.812Summary 138Creating executable146Using the filesystem 14712.1Paths and pathnames148Absolute and relative paths 148 The current workingdirectory 149 Manipulating pathnames 150 Usefulconstants and functions 153 12.212.312.412.513 Getting information about files 154More filesystem operations 155Processing all files in a directory subtreeSummary 157156Reading and writing files 15913.113.213.313.4Opening files and file objects 159Closing files 160Opening files in write or other modes 160Functions to read and write text or binary data161Using binary mode 16313.513.613.713.813.914Screen input/output and redirection 163Reading structured binary data with the struct modulePickling objects into files 167Shelving objects 170Summary 171165Exceptions 17214.1Introduction to exceptions173General philosophy of errors and exception handling 173 A moreformal definition of exceptions 175 User-defined exceptions 176 14.2Exceptions in Python176Types of Python exceptions 177 Raising exceptions 178Catching and handling exceptions 179 Defining newexceptions 180 Debugging programs with the assertstatement 181 The exception inheritance hierarchy 182 Licensed to Jay Vee metacyclist@gmail.com

xiiiCONTENTSExample: a disk-writing program in Python 182 Example:exceptions in normal evaluation 183 Where to useexceptions 184 14.314.415Using with 184Summary 185Classes and object-oriented programming15.1Defining classes186187Using a class instance as a structure or record15.215.315.4Instance variables 188Methods 188Class variables 190An oddity with class variables15.516191Static methods and class methodsStatic methods15.615.715.815.915.1015.1115.1215.13187192 192Class methods 193Inheritance 194Inheritance with class and instance variables 196Private variables and private methods 197Using @property for more flexible instance variables 198Scoping rules and namespaces for class instances 199Destructors and memory management 203Multiple inheritance 207Summary 208Graphical user interfaces 20916.116.216.3Installing Tkinter 210Starting Tk and using TkinterPrinciples of Tkinter 212211Widgets 212 Named attributes 212and widget placement 213 16.416.516.616.716.8 Geometry managementA simple Tkinter application 214Creating widgets 215Widget placement 216Using classes to manage Tkinter applicationsWhat else can Tkinter do? 219Event handling220 Canvas and text widgetsLicensed to Jay Vee metacyclist@gmail.com 218221

xivCONTENTS16.916.10Alternatives to TkinterSummary 222221PART 3 ADVANCED LANGUAGE FEATURES . 22317Regular expressions 22517.117.217.3What is a regular expression? 225Regular expressions with special charactersRegular expressions and raw strings 227226Raw strings to the rescue 22817.417.517.618Extracting matched text from strings 229Substituting text with regular expressions 232Summary 233Packages 23418.118.218.3What is a package? 234A first example 235A concrete example 236Basic use of the mathproj package 237 Loading subpackagesand submodules 238 import statements withinpackages 239 init .py files in packages 239 18.418.518.61920The all attribute 240Proper use of packages 241Summary 241Data types as objects 24219.119.219.319.419.5Types are objects, too 242Using types 243Types and user-defined classesDuck typing 245Summary 246243Advanced object-oriented features 24720.120.2What is a special method attribute? 248Making an object behave like a list 249The getitem special method attribute 249 Licensed to Jay Vee metacyclist@gmail.com How it

xvCONTENTSworks 25020.320.4 Implementing full list functionalityGiving an object full list capability 252Subclassing from built-in types 254Subclassing list20.520.620.7251254 Subclassing UserList 255When to use special method attributesMetaclasses 256Abstract base classes 258256Using abstract base classes for type checking 259 Creatingabstract base classes 260 Using the @abstractmethod and@abstractproperty decorators 260 20.8Summary262PART 4 WHERE CAN YOU GO FROM HERE? . 26321Testing your code made easy(-er) 26521.121.2Why you need to have testsThe assert statement 266Python’s debug variable21.3265266Tests in docstrings: doctests267Avoiding doctest traps 269 Tweaking doctests withdirectives 269 Pros and cons of doctests 270 21.4Using unit tests to test everything, every time270Setting up and running a single test case 270 Running thetest 272 Running multiple tests 272 Unit tests vs.doctests 273 21.522Summary 273Moving from Python 2 to Python 322.1Porting from 2 to 3274274Steps in porting from Python 2.x to 3.x22.222.322.422.5275Testing with Python 2.6 and -3 276Using 2to3 to convert the code 277Testing and common problems 279Using the same code for 2 and 3 280Using Python 2.5 or earlier 280converting back 281 Writing for Python 3.x andLicensed to Jay Vee metacyclist@gmail.com

xviCONTENTS22.623Summary281Using Python libraries 28223.1“Batteries included”—the standard library282Managing various data types 283 Manipulating files andstorage 284 Accessing operating system services 285 Usinginternet protocols and formats 286 Development and debuggingtools and runtime services 286 23.223.323.4Moving beyond the standard library 287Adding more Python libraries 287Installing Python libraries using setup.py 288Installing under the home schemeoptions 28923.523.624PyPI, a.k.a. “the Cheese Shop”Summary 289288Other installation 289Network, web, and database programming 29024.1Accessing databases in Python291Using the sqlite3 database 29124.2Network programming in Python 293Creating an instant HTTP serverclient 29424.3293Creating a Python web application Writing an HTTP295Using the web server gateway interface 295 Using the wsgilibrary to create a basic web app 295 Using frameworks to createadvanced web apps 296 24.4Sample project—creating a message wall 297Creating the database 297 Creating an applicationobject 298 Adding a form and retrieving its contents298 Saving the form’s contents 299 Parsing the URL andretrieving messages 300 Adding an HTML wrapper 303 24.5Summary304appendix 305index 323Licensed to Jay Vee metacyclist@gmail.com

prefaceI’ve been coding in Python for a number of years, longer than any other language I’veever used. I use Python for system administration, for web applications, for databasemanagement, and sometimes just to help myself think clearly.To be honest, I’m sometimes a little surprised that Python has worn so well. Basedon my earlier experience, I would have expected that by now some other languagewould have come along that was faster, cooler, sexier, whatever. Indeed, other languages have come along, but none that helped me do what I needed to do quite aseffectively as Python. In fact, the more I use Python and the more I understand it, themore I feel the quality of my programming improve and mature.This is a second edition, and my mantra in updating has been, “If it ain’t broke,don’t fix it.” Much of the content has been freshened for Python 3 but is largely aswritten in the first edition. Of course, the world of Python has changed since Python1.5, so in several places I’ve had to make significant changes or add new material. Onthose occasions I’ve done my best to make the new material compatible with the clearand low-key style of the original.For me, the aim of this book is to share the positive experiences I’ve gotten fromcoding in Python by introducing people to Python 3, the latest and, in my opinion,the best version of Python to date. May your journey be as satisfying as mine has been.xviiLicensed to Jay Vee metacyclist@gmail.com

acknowledgmentsI want to thank David Fugate of LaunchBooks for getting me into this book in the firstplace and for all of the support and advice he has provided over the years. I can’timagine having a better agent and friend. I also need to thank Michael Stephens ofManning for pushing the idea of doing a second edition of this book and supportingme in my efforts to make it as good as the first. Also at Manning, many thanks to everyperson who worked on this project, with special thanks to Marjan Bace for his support,Tara Walsh for guidance in the development phases, Mary Piergies for getting thebook (and me) through the production process, Linda Recktenwald for her patiencein copy editing, and Tiffany Taylor for proofreading. I also owe a huge debt to WillKahn-Greene for all of the astute advice he gave both as a technical reviewer and indoing the technical proofing. Thanks, Will, you saved me from myself more timesthan I can count. Likewise, hearty thanks to the many reviewers whose insights andfeedback were of immense help: Nick Lo, Michele Galli, Andy Dingley, MohamedLamkadem, Robby O'Connor, Amos Bannister, Joshua Miller, Christian Marquardt,Andrew Rhine, Anthony Briggs, Carlton Gibson, Craig Smith, Daniel McKinnon,David McWhirter, Edmon Begoli, Elliot Winard, Horaci Macias, Massimo Perga,Munch Paulson, Nathan R. Yergler, Rick Wagner, Sumit Pal, and Tyson S. Maxwell.Because this is a second edition, I have to thank the authors of the first edition,Daryl Harms and Kenneth MacDonald, for two things: first, for writing a book so soundthat it has remained in print well beyond the average lifespan of most tech books, andsecond, for being otherwise occupied, thereby giving me a chance to update it. I hopethis version carries on the successful and long-lived tradition of the first.xviiiLicensed to Jay Vee metacyclist@gmail.com

ACKNOWLEDGMENTSxixThanks to my canine associates, Molly, Riker, and Aeryn, who got fewer walks,training sessions, and games of ball than they should have but still curled up besidemy chair and kept me company and helped me keep my sense of perspective as Iworked. You’ll get those walks now, guys, I promise.Most important, thanks to my wife, Becky, who both encouraged me to take on thisproject and had to put up with the most in the course of its completion—particularlyan often-grumpy and preoccupied spouse. I really couldn’t have done it without you.Licensed to Jay Vee metacyclist@gmail.com

about this bookWho should read this bookThis book is intended for people who already have experience in one or more programming languages and want to learn the basics of Python 3 as quickly and directlyas possible. Although some basic concepts are covered, there’s no attempt to teachbasic programming skills in this book, and the basic concepts of flow control, OOP,file access, exception handling, and the like are assumed. This book may also be ofuse to users of earlier versions of Python who want a concise reference for Python 3.How to use this bookPart 1 introduces Python and explains how to download and install it on your system.It also includes a very general survey of the language, which will be most useful forexperienced programmers looking for a high-level view of Python.Part 2 is the heart of the book. It covers the ingredients necessary for obtaining aworking knowledge of Python as a general-purpose programming language. Thechapters are designed to allow readers who are beginning to learn Python to worktheir way through sequentially, picking up knowledge of the key points of the language. These chapters also contain some more advanced sections, allowing you toreturn to find in one place all the necessary information about a construct or topic.Part 3 introduces advanced language features of Python, elements of the languagethat aren’t essential to its use but that can certainly be a great help to a serious Pythonprogrammer.xxLicensed to Jay Vee metacyclist@gmail.com

ABOUT THIS BOOKxxiPart 4 describes more advanced or specialized topics that are beyond the strict syntax of the language. You may read these chapters or not, depending on your needs.A suggested plan if you’re new to Python is to start by reading chapter 3 to obtainan overall perspective and then work through the chapters in part 2 that are applicable. Enter in the interactive examples as they are introduced. This will immediatelyreinforce the concepts. You can also easily go beyond the examples in the text toanswer questions about anything that may be unclear. This has the potential toamplify the speed of your learning and the level of your comprehension. If you aren’tfamiliar with OOP or don’t need it for your application, skip most of chapter 15. If youaren’t interested in developing a GUI, skip chapter 16.Those familiar with Python should also start with chapter 3. It will be a good reviewand will introduce differences between Python 3 and what may be more familiar. It’s areasonable test of whether you’re ready to move on to the advanced chapters in parts3 and 4 of this book.It’s possible that some readers, although new to Python, will have enough experience with other programming languages to be able to pick up the bulk of what theyneed to get going from chapter 3 and by browsing the Python standard library moduleslisted in chapter 23 and the Python Library Reference in the Python documentation.RoadmapChapter 1 discusses the strengths and weaknesses of Python and shows why Python 3 isa good choice of programming language for many situations.Chapter 2 covers downloading, installing, and starting up the Python interpreterand IDLE, its integrated development environment.Chapter 3 is a short overview of the Python language. It provides a basic idea of thephilosophy, syntax, semantics, and capabilities of the language.Chapter 4 starts with the basics of Python. It introduces Python variables, expressions, strings, and numbers. It also introduces Python’s block-structured syntax.Chapters 5, 6, and 7 describe the five powerful built-in Python data types: lists,tuples, sets, strings, and dictionaries.Chapter 8 introduces Python’s control flow syntax and use (loops and if-elsestatements).Chapter 9 describes function definition in Python along with its flexible parameter-passing capabilities.Chapter 10 describes Python modules. They provide an easy mechanism for segmenting the program namespace.Chapter 11 covers creating standalone Python programs, or scripts, and runningthem on Windows, Mac OS X, and Linux platforms. The chapter also covers the support available for command-line options, arguments, and I/O redirection.Licensed to Jay Vee metacyclist@gmail.com

xxiiABOUT THIS BOOKChapter 12 describes how to work and navigate through the files and directories ofthe filesystem. It shows how to write code that’s as independent as possible of theactual operating system you’re working on.Chapter 13 introduces the mechanisms for reading and writing files in Python.These include the basic capability to read and write strings (or byte streams), themechanism available for reading binary records, and the ability to read and write arbitrary Python objects.Chapter 14 discusses the use of exceptions, the error-handling mechanism used byPython. It doesn’t assume that you have any prior knowledge of exceptions, althoughif you’ve previously used them in C or Java, you’ll find them familiar.Chapter 15 introduces Python’s support for writing object-oriented programs.Chapter 16 focuses on the available Tkinter interface and ends with an introduction to some of the other options available for developing GUIs.Chapter 17 discusses the regular-expression capabilities available for Python.Chapter 18 introduces the package concept in Python for structuring the code oflarge projects.Chapter 19 covers the simple mechanisms available to dynamically discover andwork with data types in Python.Chapter 20 introduces more advanced OOP techniques, including the use ofPython’s special method-attributes mechanism, metaclasses, and abstract base classes.Chapter 21 covers two strategies that Python offers for testing your code: doctestsand unit testing.Chapter 22 surveys the process, issues, and tools involved in porting code from earlier versions of Python to Python 3.Chapter 23 is a brief survey of the standard library and also includes a discussion ofwhere to find other modules and how to install them.Chapter 24 is a brief introduction to using Python for database and web programming. A small web application is developed to illustrate the principles involved.The appendix contains a comprehensive guide to obtaining and accessingPython’s full documentation, the Pythonic style guide, PEP 8, and “The Zen ofPython,” a slightly wry summary of the philosophy behind Python.Code conventionsThe code samples in this book, and their output, appear in a fixed-width font andare often accompanied by annotations. The code samples are deliberately kept as simple as possible, because they aren’t intended to be reusable parts that can pluggedinto your code. Instead, the code samples are stripped down so that you can focus onthe principle being illustrated.In keeping with the idea of simplicity, the code examples are presented as interactive shell sessions where possible; you should enter and experiment with these samplesas much as you can. In interactive code samples, the commands that need to beentered are on lines that begin with the prompt, and the visible results of thatcode (if any) are on the line below.Licensed to Jay Vee metacyclist@gmail.com

ABOUT THIS BOOKxxiiiIn some cases a longer code sample is needed, and these are identified in the textas file listings. You should save these as files with names matching those used in thetext and run them as standalone scripts.Source code downloadsThe source code for the samples in this book is available from the publisher’s websiteat stem requirementsThe samples and code in this book have been written with Windows (XP through Windows 7), Mac OS X, and Linux in mind. Because Python is a cross-platform language,they should work on other platforms for the most part, except for platform-specificissues, like the handling of files, paths, and GUIs.Software requirementsThis book is based on Python 3.1, and all examples should work on any subsequentversion of Python 3. The examples also work on Python 3.0, but I strongly recommendusing 3.1—there are no advantages to the earlier version, and 3.1 has several subtleimprovements. Note that Python 3 is required and that an earlier version of Python willnot work with the code in this book.Author OnlineThe purchase of The Quick Python Book, Second Edition includes free access to a privateweb forum run by Manning Publications, where you can make comments about thebook, ask technical questions, and receive help from the author and from other users.To access the forum and subscribe to it, point your web browser to www.manning.com/TheQuickPythonBookSecondEdition. This page provides information abouthow to get on the forum once you’re registered, what kind of help is available, and therules of conduct on the forum.Manning’s commitment to our readers is to provide a venue where a meaningfuldialogue between individual readers and between readers and the author can takeplace. It’s not a commitment to any specific amount of participation on the part of theauthor, whose contribution to the book’s forum remains voluntary (and unpaid). Wesuggest you try asking him some challenging questions, lest his interest stray!The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.About the authorSecond edition author Naomi Ceder has been programming in various languages forover 20 years and has been a Linux system administrator since 2000. She started usingPython for a variety of projects in 2001. She is currently IT Director at Zoro Tools, Inc., inBuffalo Grove, Illinois, and an organizer and teacher of the Chicago Python Workshops.Licensed to Jay Vee metacyclist@gmail.com

xxivABOUT THIS BOOKAbout the cover illustrationThe illustration on the cover of The Quick Python Book, Second Edition is taken from alate 18th century edition of Sylvain Maréchal’s four-volume compendium of regionaldress customs published in France. Each illustration is finely drawn and colored byhand. The rich variety of Maréchal’s collection reminds us vividly of how culturallyapart the world’s towns and regions were just 200 years ago. Isolated from each other,people spoke different dialects and languages. In the streets or in the countryside, itwas easy to identify where they lived and what their trade or station in life was just bywhat they were wearing.Dress codes have changed since then and the diversity by region, so rich at thetime, has faded away. It is now hard to tell apart the inhabitants of different continents, let alone different towns or regions. Perhaps we have traded cultural diversityfor a more varied personal life—certainly for a more varied and fast-paced technological life.At a time when it is hard to tell one computer book from another, Manning celebrates the inventiveness and initiative of the computer business with book coversbased on the rich diversity of regional life of two centuries ago, brought back to life byMaréchal’s pictures.Licensed to Jay Vee metacyclist@gmail.com

Part 1Starting outThis section will tell you a little bit about Python, its strengths and weaknesses, and why you should consider learning P

Python is readable 5 Python is complete—"batteries included" 6 Python is cross-platform 6 Python is free 6 1.3 What Python doesn't do as well 7 Python is not the fastest language 7 Python doesn't have the most libraries 8 Python doesn't check variable types at compile time 8 1.4 Why learn Python 3? 8 1.5 Summary 9

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

Python Programming for the Absolute Beginner Second Edition. CONTENTS CHAPTER 1 GETTING STARTED: THE GAME OVER PROGRAM 1 Examining the Game Over Program 2 Introducing Python 3 Python Is Easy to Use 3 Python Is Powerful 3 Python Is Object Oriented 4 Python Is a "Glue" Language 4 Python Runs Everywhere 4 Python Has a Strong Community 4 Python Is Free and Open Source 5 Setting Up Python on .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Python 2 versus Python 3 - the great debate Installing Python Setting up the Python interpreter About virtualenv Your first virtual environment Your friend, the console How you can run a Python program Running Python scripts Running the Python interactive shell Running Python as a service Running Python as a GUI application How is Python code .

Waterhead 1003 1346 St James 1041 1393 Chadderton South 1370 964 Failsworth West 1596 849 Chadderton North 2038 791 Chadderton Central 2096 695 Failsworth East 2234 643 Shaw 2295 893 Royton South 3008 628 Royton North 3297 808 Crompton 3858 510 Saddleworth West and Lees 3899 380 Saddleworth North 5892 309 Saddleworth South 6536 260 3.3 There is a wealth of evidence to suggest links between .