资源描述:
《Python_Cookbook_3rd_Edition.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、PythonCookbookDavidBeazleyBrianK.JonesBeijing•Cambridge•Farnham•Köln•Sebastopol•TokyoSpecialUpgradeOfferIfyoupurchasedthisebookdirectlyfromoreilly.com,youhavethefollowingbenefits:DRM-freeebooks—useyourebooksacrossdeviceswithoutrestrictionsorlimitationsMultipleformats—us
2、eonyourlaptop,tablet,orphoneLifetimeaccess,withfreeupdatesDropboxsyncing—yourfiles,anywhereIfyoupurchasedthisebookfromanotherretailer,youcanupgradeyourebooktotakeadvantageofallthesebenefitsforjust$4.99.Clickheretoaccessyourebookupgrade.Pleasenotethatupgradeoffersarenota
3、vailablefromsamplecontent.PrefaceSince2008,thePythonworldhasbeenwatchingtheslowevolutionofPython3.ItwasalwaysknownthattheadoptionofPython3wouldlikelytakealongtime.Infact,evenatthetimeofthiswriting(2013),mostworkingPythonprogrammerscontinuetousePython2inproduction.Alotha
4、sbeenmadeaboutthefactthatPython3isnotbackwardcompatiblewithpastversions.Tobesure,backwardcompatibilityisanissueforanyonewithanexistingcodebase.However,ifyoushiftyourviewtowardthefuture,you’llfindthatPython3offersmuchmorethanmeetstheeye.JustasPython3isaboutthefuture,this
5、editionofthePythonCookbookrepresentsamajorchangeoverpasteditions.Firstandforemost,thisismeanttobeaveryforwardlookingbook.AlloftherecipeshavebeenwrittenandtestedwithPython3.3withoutregardtopastPythonversionsorthe“oldway”ofdoingthings.Infact,manyoftherecipeswillonlyworkwi
6、thPython3.3andabove.Doingsomaybeacalculatedrisk,buttheultimategoalistowriteabookofrecipesbasedonthemostmoderntoolsandidiomspossible.ItishopedthattherecipescanserveasaguideforpeoplewritingnewcodeinPython3orthosewhohopetomodernizeexistingcode.Needlesstosay,writingabookofr
7、ecipesinthisstylepresentsacertaineditorialchallenge.AnonlinesearchforPythonrecipesreturnsliterallythousandsofusefulrecipesonsitessuchasActiveState’sPythonrecipesorStackOverflow.However,mostoftheserecipesaresteepedinhistoryandthepast.Besidesbeingwrittenalmostexclusivelyf
8、orPython2,theyoftencontainworkaroundsandhacksrelatedtodifferencesbetweenoldversionsofPython(e.g.,version2.3ver