第9页 | Dive Into Python 3 | 阅读 ‧ 电子书库

同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库

Document Outline

 

 

 

 
What’s New In “Dive Into Python 3” a.k.a. “the minus level” Installing Python Diving InWhich Python Is Right For You? Installing on Microsoft WindowsInstalling on Mac OS XInstalling on Ubuntu LinuxInstalling on Other PlatformsUsing The Python ShellPython Editors and IDEsYour First Python Program Diving InDeclaring Functions Optional and Named ArgumentsWriting Readable Code Documentation StringsThe import Search PathEverything Is An Object What’s An Object? Indenting CodeExceptions Catching Import ErrorsUnbound VariablesEverything is Case-SensitiveRunning ScriptsFurther ReadingNative Datatypes Diving InBooleansNumbers Coercing Integers To Floats And Vice-VersaCommon Numerical OperationsFractionsTrigonometryNumbers In A Boolean ContextLists Creating A ListSlicing A ListAdding Items To A ListSearching For Values In A ListRemoving Items From A ListRemoving Items From A List: Bonus RoundLists In A Boolean ContextTuples Tuples In A Boolean ContextAssigning Multiple Values At OnceSets Creating A SetModifying A SetRemoving Items From A SetCommon Set OperationsSets In A Boolean ContextDictionaries Creating A DictionaryModifying A DictionaryMixed-Value DictionariesDictionaries In A Boolean ContextNone None In A Boolean ContextFurther ReadingComprehensions Diving InWorking With Files And Directories The Current Working DirectoryWorking With Filenames and Directory NamesListing DirectoriesGetting File MetadataConstructing Absolute PathnamesList ComprehensionsDictionary Comprehensions Other Fun Stuff To Do With Dictionary ComprehensionsSet ComprehensionsFurther ReadingStrings Some Boring Stuff You Need To Understand Before You Can Dive InUnicodeDiving InFormatting Strings Compound Field NamesFormat SpecifiersOther Common String Methods Slicing A StringStrings vs. BytesPostscript: Character Encoding Of Python Source CodeFurther ReadingRegular Expressions Diving InCase Study: Street AddressesCase Study: Roman Numerals Checking For ThousandsChecking For HundredsUsing The {n,m} Syntax Checking For Tens And OnesVerbose Regular ExpressionsCase study: Parsing Phone NumbersSummaryClosures & Generators Diving InI Know, Let’s Use Regular Expressions! A List Of FunctionsA List Of PatternsA File Of PatternsGenerators A Fibonacci GeneratorA Plural Rule GeneratorFurther ReadingClasses & Iterators Diving InDefining Classes The __init__() MethodInstantiating ClassesInstance VariablesA Fibonacci IteratorA Plural Rule IteratorFurther ReadingAdvanced Iterators Diving InFinding all occurrences of a patternFinding the unique items in a sequenceMaking assertionsGenerator expressionsCalculating Permutations… The Lazy Way! Other Fun Stuff in the itertools ModuleA New Kind Of String ManipulationEvaluating Arbitrary Strings As Python ExpressionsPutting It All TogetherFurther ReadingUnit Testing (Not) Diving InA Single Question“Halt And Catch Fire” More Halting, More FireAnd One More Thing…A Pleasing SymmetryMore Bad InputRefactoring Diving InHandling Changing RequirementsRefactoringSummaryFiles Diving InReading From Text Files Character Encoding Rears Its Ugly HeadStream ObjectsReading Data From A Text FileClosing FilesClosing Files AutomaticallyReading Data One Line At A TimeWriting to Text Files Character Encoding AgainBinary FilesStream Objects From Non-File Sources Handling Compressed FilesStandard Input, Output, and Error Redirecting Standard OutputFurther ReadingXML Diving InA 5-Minute Crash Course in XMLThe Structure Of An Atom FeedParsing XML Elements Are ListsAttributes Are DictonariesSearching For Nodes Within An XML DocumentGoing Further With lxmlGenerating XMLParsing Broken XMLFurther ReadingSerializing Python Objects Diving In A Quick Note About The Examples in This ChapterSaving Data to a Pickle FileLoading Data from a Pickle FilePickling Without a FileBytes and Strings Rear Their Ugly Heads AgainDebugging Pickle FilesSerializing Python Objects to be Read by Other LanguagesSaving Data to a JSON FileMapping of Python Datatypes to JSONSerializing Datatypes Unsupported by JSONLoading Data from a JSON FileFurther ReadingHTTP Web Services Diving InFeatures of HTTP CachingLast-Modified CheckingETag CheckingCompressionRedirectsHow Not To Fetch Data Over HTTPWhat’s On The Wire? Introducing httplib2 A Short Digression To Explain Why httplib2 Returns Bytes Instead of StringsHow httplib2 Handles CachingHow httplib2 Handles Last-Modified and ETag HeadersHow http2lib Handles CompressionHow httplib2 Handles RedirectsBeyond HTTP GETBeyond HTTP POSTFurther ReadingCase Study: Porting chardet to Python 3 Diving InWhat is Character Encoding Auto-Detection? Isn’t That Impossible? Does Such An Algorithm Exist? Introducing The chardet Module UTF-n With A BOMEscaped EncodingsMulti-Byte EncodingsSingle-Byte Encodingswindows-1252Running 2to3A Short Digression Into Multi-File ModulesFixing What 2to3 Can’t False is invalid syntaxNo module named constantsName 'file' is not definedCan’t use a string pattern on a bytes-like objectCan't convert 'bytes' object to str implicitlyUnsupported operand type(s) for +: 'int' and 'bytes' ord() expected string of length 1, but int foundUnorderable types: int() >= str()Global name 'reduce' is not definedSummaryPackaging Python Libraries Diving InThings Distutils Can’t Do For YouDirectory StructureWriting Your Setup ScriptClassifying Your Package Examples of Good Package ClassifiersSpecifying Additional Files With A ManifestChecking Your Setup Script for ErrorsCreating a Source DistributionCreating a Graphical Installer Building Installable Packages for Other Operating SystemsAdding Your Software to The Python Package IndexThe Many Possible Futures of Python PackagingFurther ReadingPorting Code to Python 3 with 2to3 Diving Inprint statementUnicode string literalsunicode() global functionlong data type<> comparisonhas_key() dictionary methodDictionary methods that return listsModules that have been renamed or reorganized httpurllibdbmxmlrpcOther modulesRelative imports within a packagenext() iterator methodfilter() global functionmap() global functionreduce() global functionapply() global functionintern() global functionexec statementexecfile statementrepr literals (backticks)try...except statementraise statementthrow method on generatorsxrange() global functionraw_input() and input() global functionsfunc_* function attributesxreadlines() I/O methodlambda functions that take a tuple instead of multiple parametersSpecial method attributes__nonzero__ special methodOctal literalssys.maxintcallable() global functionzip() global functionStandardError exceptiontypes module constantsisinstance() global functionbasestring datatypeitertools modulesys.exc_type, sys.exc_value, sys.exc_tracebackList comprehensions over tuplesos.getcwdu() functionMetaclassesMatters of style set() literals (explicit)buffer() global function (explicit)Whitespace around commas (explicit)Common idioms (explicit)Special Method Names Diving InBasicsClasses That Act Like IteratorsComputed AttributesClasses That Act Like FunctionsClasses That Act Like SetsClasses That Act Like DictionariesClasses That Act Like NumbersClasses That Can Be ComparedClasses That Can Be SerializedClasses That Can Be Used in a with BlockReally Esoteric StuffFurther ReadingWhere To Go From Here Things to ReadWhere To Look For Python 3-Compatible CodeTroubleshooting Diving InGetting to the Command LineRunning Python on the command line

请支持我们,让我们可以支付服务器费用。
使用微信支付打赏


上一页 · 目录下一页


下载 · 书页 · 阅读 ‧ 电子书库