به دنیای پایتون ۳: [هر آنچه برای شروع کار با پایتون ۳ نیاز دارید]
Dive into Python 3 : [all you need to know to get off the ground with Python 3
معرفی کتاب «به دنیای پایتون ۳: [هر آنچه برای شروع کار با پایتون ۳ نیاز دارید]» (با عنوان لاتین Dive into Python 3 : [all you need to know to get off the ground with Python 3) نوشتهٔ Mark Pilgram، منتشرشده توسط نشر Apress : Imprint : Apress در سال 2009. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Mark Pilgrim 's Dive Into Python 3 is a hands-on guide to Python 3 and its differences from Python 2. As in the original book, Dive Into Python , each chapter starts with a real, complete code sample, proceeds to pick it apart and explain the pieces, and then puts it all back together in a summary at the end. This book includes: Example programs completely rewritten to illustrate powerful new concepts now available in Python 3: sets, iterators, generators, closures, comprehensions, and much more A detailed case study of porting a major library from Python 2 to Python 3 A comprehensive appendix of all the syntactic and semantic changes in Python 3 This is the perfect resource for you if you need to port applications to Python 3, or if you like to jump into languages fast and get going right away. What you’ll learn To understand Python 3 code by seeing it broken down and explained How to make full use of the latest Python features such as iterators, generators, closures, classes and comprehensions How to refactor existing code to improve maintainability How to serialize Python objects with the pickle protocol and JSON format How to package your own Python libraries and upload them to the Python Package Index to share your projects with Python developers worldwide How to use Python 3 to consume HTTP web services How to port existing Python applications to Python 3 by following a case study for a major library Who this book is for Anyone who wants to learn the latest version of Python in a fast, hands-on fashion Existing Python programmers who want to learn quickly how to make the most of the features of the latest version of Python and port their code to it Programmers coming from other languages wanting a fast introduction to Python that gets them thinking about advanced concepts quickly Table of Contents Your First Python Program Native Datatypes Comprehensions Strings Regular Expressions Closures and Generators Classes and Iterators Advanced Iterators Unit Testing Refactoring Files XML Serializing Python Objects HTTP Web Services Case Study: Porting chardet to Python 3 Packaging Python Libraries Title page ......Page 2 Copyright Page ......Page 3 Contents at a Glance......Page 5 Table of Contents ......Page 6 Foreword......Page 14 About the Author......Page 16 About the Technical Reviewer......Page 17 Acknowledgments......Page 18 Which Python Is Right for You?......Page 19 Installing on Microsoft Windows......Page 20 Installing on Mac OS X......Page 29 Installing on Ubuntu Linux......Page 41 Using the Python Shell......Page 48 Python Editors and IDEs......Page 50 CHAPTER 1 Your First Python Program......Page 52 Declaring Functions......Page 53 Optional and Named Arguments......Page 54 Documentation Strings......Page 56 The import Search Path......Page 57 Everything Is an Object......Page 58 Indenting Code......Page 59 Exceptions......Page 60 Catching Import Errors......Page 62 Running Scripts......Page 63 Further Reading Online......Page 64 Booleans......Page 65 Numbers......Page 66 Coercing Integers to Floats and Vice Versa......Page 67 Common Numerical Operations......Page 68 Fractions......Page 69 Numbers in a Boolean Context......Page 70 Creating a List......Page 71 Slicing a List......Page 72 Adding Items to a List......Page 73 Searching For Values in a List......Page 75 Removing Items from a List: Bonus Round......Page 76 Lists in a Boolean Context......Page 77 Tuples......Page 78 Assigning Multiple Values at Once......Page 80 Sets......Page 81 Modifying a Set......Page 83 Removing Items from a Set......Page 84 Common Set Operations......Page 85 Sets in a Boolean Context......Page 87 Modifying a Dictionary......Page 88 Mixed-Value Dictionaries......Page 89 Dictionaries in a Boolean Context......Page 90 None in a Boolean Context......Page 91 Further Reading Online......Page 92 The Current Working Directory......Page 93 Working with Filenames and Directory Names......Page 94 Listing Directories......Page 96 Constructing Absolute Pathnames......Page 97 List Comprehensions......Page 98 Dictionary Comprehensions......Page 100 Set Comprehensions......Page 101 Further Reading Online......Page 102 CHAPTER 4 Strings ......Page 103 Unicode......Page 104 Formatting Strings......Page 106 Compound Field Names......Page 107 Format Specifiers......Page 109 Other Common String Methods......Page 110 Slicing a String......Page 111 Strings versus Bytes......Page 112 Character Encoding of Python Source Code......Page 115 Further Reading Online......Page 116 Case Study: Street Addresses......Page 118 Case Study: Roman Numerals......Page 120 Checking for Thousands......Page 121 Checking for Hundreds......Page 122 Using the {n,m} Syntax......Page 124 Checking for Tens and Ones......Page 125 Verbose Regular Expressions......Page 127 Case Study: Parsing Phone Numbers......Page 129 Further Reading Online......Page 134 CHAPTER 6 Closures and Generators ......Page 135 I Know, Let’s Use Regular Expressions!......Page 136 A List of Functions......Page 138 A List of Patterns......Page 140 A File of Patterns......Page 143 Generators......Page 144 A Fibonacci Generator......Page 146 A Plural Rule Generator......Page 147 Further Reading Online......Page 148 CHAPTER 7 Classes and Iterators ......Page 149 The __init__() Method......Page 150 Instantiating Classes......Page 151 Instance Variables......Page 152 A Fibonacci Iterator......Page 153 A Plural Rule Iterator......Page 155 Further Reading Online......Page 160 CHAPTER 8 Advanced Iterators ......Page 161 Finding the Unique Items in a Sequence......Page 163 Generator Expressions......Page 165 Calculating Permutations ... the Lazy Way......Page 167 Other Fun Stuff in the itertools Module......Page 168 A New Kind of String Manipulation......Page 172 Evaluating Arbitrary Strings as Python Expressions......Page 174 Further Reading Online......Page 178 CHAPTER 9 Unit Testing ......Page 179 A Single Question......Page 180 Halt and Catch Fire......Page 186 More Halting, More Fire......Page 189 And One More Thing .........Page 192 A Pleasing Symmetry......Page 194 More Bad Input......Page 198 CHAPTER 10 Refactoring ......Page 202 Handling Changing Requirements......Page 205 Refactoring......Page 209 Further Reading Online......Page 213 Reading from Text Files......Page 214 Character Encoding Rears Its Ugly Head......Page 215 Stream Objects......Page 216 Reading Data from a Text File......Page 217 Closing Files......Page 219 Reading Data One Line at a Time......Page 220 Writing to Text Files......Page 222 Character Encoding Again......Page 223 Binary Files......Page 224 Streams Objects from Nonfile Sources......Page 225 Handling Compressed Files......Page 226 Standard Input, Output, and Error......Page 227 Redirecting Standard Output......Page 228 Further Reading Online......Page 231 CHAPTER 12 XML......Page 232 A 5-Minute Crash Course in XML......Page 233 The Structure of an Atom Feed......Page 236 Parsing XML......Page 238 Elements Are Lists......Page 239 Attributes Are Dictionaries......Page 240 Searching for Nodes Within an XML Document......Page 241 Going Further with lxml......Page 244 Generating XML......Page 246 Parsing Broken XML......Page 249 Further Reading Online......Page 251 A Quick Note About the Examples in this Chapter......Page 252 Saving Data to a Pickle File......Page 253 Loading Data from a Pickle File......Page 255 Pickling Without a File......Page 256 Debugging Pickle Files......Page 257 Saving Data to a JSON File......Page 260 Serializing Datatypes Unsupported by JSON......Page 262 Loading Data from a JSON File......Page 267 Further Reading Online......Page 269 CHAPTER 14 HTTP Web Services ......Page 271 Caching......Page 272 Last-Modified Checking......Page 273 ETags......Page 274 Redirects......Page 275 How Not to Fetch Data Over HTTP......Page 276 What’s On the Wire?......Page 277 Introducing httplib2......Page 280 Caching with httplib2......Page 283 Handling Last-Modified and ETag Headers with httplib2......Page 286 Handling Compression with httplib2......Page 288 Handling Redirects with httplib2......Page 289 Beyond HTTP GET......Page 292 Beyond HTTP POST......Page 296 Further Reading Online......Page 298 Why Auto-Detection Is Difficult......Page 299 Escaped Encodings......Page 300 Single-Byte Encodings......Page 301 Running 2to3......Page 302 A Short Digression Into Multi-File Modules......Page 305 False Is Invalid Syntax......Page 307 No Module Named Constants......Page 308 Name 'file' Is Not Defined......Page 309 Can’t Use a String Pattern on a Bytes-Like Object......Page 310 Can’t Convert 'bytes' Object to str Implicitly......Page 312 Unsupported Operand type(s) for +: 'int' and 'bytes'......Page 315 ord() Expected String of Length 1, but int Found......Page 316 Unorderable Types: int() >= str()......Page 319 Global Name 'reduce' Is not Defined......Page 321 Lessons Learned......Page 323 CHAPTER 16 Packaging Python Libraries......Page 324 Things Distutils Can’t Do for You......Page 325 Directory Structure......Page 326 Writing Your Setup Script......Page 327 Examples of Good Package Classifiers......Page 329 Creating a Source Distribution......Page 332 Creating a Graphical Installer......Page 334 Building Installable Packages for Other Operating Systems......Page 335 Adding Your Software to the Python Package Index......Page 336 The Many Possible Futures of Python Packaging......Page 337 Further Reading Online......Page 338 print Statement......Page 339 unicode() Global Function......Page 340 Comparison......Page 341 has_key() Dictionary Method......Page 342 Renamed or Reorganized Modules......Page 343 urllib......Page 344 dbm......Page 345 Other Modules......Page 346 Relative Imports Within a Package......Page 348 next() Iterator Method......Page 349 map() Global Function......Page 350 reduce() Global Function......Page 351 intern() Global Function......Page 352 execfile Statement......Page 353 try...except Statement......Page 354 throw Method on Generators......Page 356 xrange() Global Function......Page 357 func_* Function Attributes......Page 358 xreadlines() I/O Method......Page 359 lambda Functions that Take a Tuple Instead of Multiple Parameters ......Page 360 __nonzero__ Special Method......Page 361 sys.maxint......Page 362 StandardError Exception......Page 363 types Module Constants......Page 364 basestring Datatype......Page 365 sys.exc_type, sys.exc_value, sys.exc_traceback......Page 366 Metaclasses......Page 367 buffer() Global Function (Explicit)......Page 368 Common Idioms (Explicit)......Page 369 Basics......Page 371 Computed Attributes......Page 372 Classes that Act Like Functions......Page 375 Classes that Act Like Sequences......Page 376 Classes that Act Like Dictionaries......Page 378 Classes that Act Like Numbers......Page 379 Classes that Can Be Compared......Page 383 Classes that Can Be Used in a “with” Block......Page 384 Really Esoteric Stuff......Page 386 Further Reading Online......Page 387 APPENDIX C Where to Go From Here ......Page 388 Index......Page 390 Mark Pilgrim 's Dive Into Python 3 is a hands-on guide to Python 3 and its differences from Python 2. As in the original book, Dive Into Python, each chapter starts with a real, complete code sample, proceeds to pick it apart and explain the pieces, and then puts it all back together in a summary at the end. This book includes: Example programs completely rewritten to illustrate powerful new concepts now available in Python 3: sets, iterators, generators, closures, comprehensions, and much more A detailed case study of porting a major library from Python 2 to Python 3 A comprehensive appendix of all the syntactic and semantic changes in Python 3 This is the perfect resource for you if you need to port applications to Python 3, or if you like to jump into languages fast and get going right away.
دانلود کتاب به دنیای پایتون ۳: [هر آنچه برای شروع کار با پایتون ۳ نیاز دارید]