Author(s): Goal Kicker
Year: 2018
Language: English
Pages: 816
Tags: python, programming
Content list......Page 2
About......Page 26
Section 1.1: Getting Started......Page 27
Section 1.2: Creating variables and assigning values......Page 31
Section 1.3: Block Indentation......Page 35
Section 1.4: Datatypes......Page 36
Section 1.5: Collection Types......Page 40
Section 1.6: IDLE - Python GUI......Page 44
Section 1.8: Built in Modules and Functions......Page 46
Section 1.9: Creating a module......Page 50
Section 1.10: Installation of Python 2.7.x and 3.x......Page 51
Section 1.11: String function - str() and repr()......Page 53
Section 1.12: Installing external modules using pip......Page 54
Section 1.13: Help Utility......Page 56
Section 2.3: Numbers data type......Page 58
Section 2.6: Tuple Data Type......Page 59
Section 3.2: How Indentation is Parsed......Page 60
Section 3.3: Indentation Errors......Page 61
Section 4.2: Programmatically accessing docstrings......Page 62
Section 4.3: Write documentation using docstrings......Page 63
Section 5.2: Constructing timezone-aware datetimes......Page 66
Section 5.4: Basic datetime objects usage......Page 68
Section 5.6: Simple date arithmetic......Page 69
Section 5.9: Parsing an arbitrary ISO 8601 timestamp with minimal libraries......Page 70
Section 5.11: Parsing a string with a short time zone name into a timezone aware datetime object......Page 71
Section 5.12: Fuzzy datetime parsing (extracting datetime out of a text)......Page 72
Section 5.13: Iterate over dates......Page 73
Section 6.3: Parsing string to datetime object......Page 74
Section 7.2: Iteration......Page 75
Section 8.1: Operations on sets......Page 76
Section 8.4: Set Operations using Methods and Builtins......Page 77
Section 8.5: Sets versus multisets......Page 79
Section 9.1: Division......Page 81
Section 9.2: Addition......Page 82
Section 9.3: Exponentiation......Page 83
Section 9.4: Trigonometric Functions......Page 84
Section 9.7: Multiplication......Page 85
Section 9.9: Modulus......Page 86
Section 10.1: Bitwise NOT......Page 88
Section 10.2: Bitwise XOR (Exclusive OR)......Page 89
Section 10.5: Bitwise Left Shift......Page 90
Section 10.7: Inplace Operations......Page 91
Section 11.3: Short-circuit evaluation......Page 92
Section 11.5: or......Page 93
Section 11.6: not......Page 94
Section 12.1: Simple Operator Precedence Examples in python......Page 95
Section 13.2: Global Variables......Page 96
Section 13.3: Local Variables......Page 97
Section 13.4: The del command......Page 98
Section 13.5: Functions skip class scope when looking up names......Page 99
Section 13.6: Local vs Global Scope......Page 100
Section 13.7: Binding Occurrence......Page 102
Section 14.3: Truth Values......Page 103
Section 14.4: Boolean Logic Expressions......Page 104
Section 14.6: Else statement......Page 106
Section 14.8: If statement......Page 107
Section 15.1: Chain Comparisons......Page 108
Section 15.2: Comparison by `is` vs `==`......Page 109
Section 15.4: Not equal to......Page 110
Section 15.6: Comparing Objects......Page 111
Section 16.1: Break and Continue in Loops......Page 113
Section 16.3: Iterating over lists......Page 115
Section 16.4: Loops with an "else" clause......Page 116
Section 16.5: The Pass Statement......Page 118
Section 16.6: Iterating over dictionaries......Page 119
Section 16.8: Looping and Unpacking......Page 120
Section 16.9: Iterating dierent portion of a list with dierent step size......Page 121
Section 16.10: While Loop......Page 122
Section 17.2: Basic Introduction to Arrays......Page 124
Section 17.5: Extend python array using extend() method......Page 125
Section 17.10: Reverse a python array using reverse() method......Page 126
Section 17.15: Append a string to char array using fromstring() method......Page 127
Section 18.2: Lists in lists in lists in........Page 128
Section 19.1: Introduction to Dictionary......Page 130
Section 19.3: Iterating Over a Dictionary......Page 131
Section 19.4: Dictionary with default values......Page 132
Section 19.6: Accessing keys and values......Page 133
Section 19.8: Creating a dictionary......Page 134
Section 19.10: Unpacking dictionaries using the ** operator......Page 135
Section 19.13: Dictionaries Example......Page 136
Section 19.14: All combinations of dictionary values......Page 137
Section 20.1: List methods and supported operators......Page 138
Section 20.2: Accessing list values......Page 143
Section 20.4: Iterating over a list......Page 144
Section 20.6: Any and All......Page 145
Section 20.8: Concatenate and Merge lists......Page 146
Section 20.10: Remove duplicate values in list......Page 147
Section 20.12: Accessing values in nested list......Page 148
Section 20.13: Initializing a List to a Fixed Number of Elements......Page 149
Section 21.1: List Comprehensions......Page 151
Section 21.2: Conditional List Comprehensions......Page 153
Section 21.3: Avoid repetitive and expensive operations using conditional clause......Page 155
Section 21.4: Dictionary Comprehensions......Page 156
Section 21.5: List Comprehensions with Nested Loops......Page 157
Section 21.6: Generator Expressions......Page 159
Section 21.8: Refactoring filter and map to list comprehensions......Page 161
Section 21.9: Comprehensions involving tuples......Page 162
Section 21.12: Nested List Comprehensions......Page 163
Section 21.13: Iterate two or more list simultaneously within list comprehension......Page 164
Section 22.4: Shifting a list using slicing......Page 165
Section 23.2: Example 2......Page 167
Section 23.3: Example 3......Page 168
Section 24.1: Single linked list example......Page 170
Section 25.1: Write a simple Linked List Node in python......Page 174
Section 26.2: Filter without function......Page 175
Section 26.4: Complementary function: filterfalse, ifilterfalse......Page 176
Section 27.2: Smallest item in a collection......Page 178
Section 28.1: Tuple......Page 180
Section 28.3: Packing and Unpacking Tuples......Page 181
Section 28.4: Built-in Tuple Functions......Page 182
Section 28.5: Tuple Are Element-wise Hashable and Equatable......Page 183
Section 28.7: Reversing Elements......Page 184
Section 29.2: Input from a File......Page 185
Section 29.5: Function to prompt user for a number......Page 187
Section 29.6: Printing a string without a newline at the end......Page 188
Section 30.1: File modes......Page 190
Section 30.2: Reading a file line-by-line......Page 191
Section 30.4: Getting the full contents of a file......Page 192
Section 30.5: Writing to a file......Page 193
Section 30.6: Check whether a file or path exists......Page 194
Section 30.9: Checking if a file is empty......Page 195
Section 30.12: Copying contents of one file to a dierent file......Page 196
Section 31.4: If the given path exists......Page 197
Section 31.6: Absolute Path from Relative Path......Page 198
Section 32.1: Iterator vs Iterable vs Generator......Page 199
Section 32.4: Verify only one element in iterable......Page 200
Section 32.6: Iterator isn't reentrant!......Page 201
Section 33.1: Defining and calling simple functions......Page 202
Section 33.2: Defining a function with an arbitrary number of arguments......Page 203
Section 33.3: Lambda (Inline/Anonymous) Functions......Page 206
Section 33.4: Defining a function with optional arguments......Page 208
Section 33.5: Defining a function with optional mutable arguments......Page 209
Section 33.6: Argument passing and mutability......Page 210
Section 33.8: Closure......Page 211
Section 33.9: Forcing the use of named parameters......Page 212
Section 33.11: Recursion limit......Page 213
Section 33.13: Recursive functions......Page 214
Section 33.15: Iterable and dictionary unpacking......Page 215
Section 33.16: Defining a function with multiple arguments......Page 217
Section 34.1: Function and Call......Page 218
Section 35.4: Filter Function......Page 219
Section 36.1: Raise the power......Page 220
Section 37.1: Decorator function......Page 221
Section 37.2: Decorator class......Page 222
Section 37.3: Decorator with arguments (decorator factory)......Page 223
Section 37.5: Using a decorator to time a function......Page 225
Section 37.6: Create singleton class with a decorator......Page 226
Section 38.1: Introduction to classes......Page 227
Section 38.2: Bound, unbound, and static methods......Page 228
Section 38.3: Basic inheritance......Page 230
Section 38.5: New-style vs. old-style classes......Page 232
Section 38.6: Class methods: alternate initializers......Page 233
Section 38.7: Multiple Inheritance......Page 235
Section 38.8: Properties......Page 237
Section 38.9: Default values for instance variables......Page 238
Section 38.10: Class and instance variables......Page 239
Section 38.11: Class composition......Page 240
Section 38.12: Listing All Class Members......Page 241
Section 38.13: Singleton class......Page 242
Section 38.14: Descriptors and Dotted Lookups......Page 243
Section 39.1: Basic Metaclasses......Page 244
Section 39.4: Introduction to Metaclasses......Page 245
Section 39.5: Custom functionality with metaclasses......Page 246
Section 39.6: The default metaclass......Page 247
Section 40.1: Basics of String Formatting......Page 249
Section 40.2: Alignment and padding......Page 250
Section 40.4: Float formatting......Page 251
Section 40.5: Named placeholders......Page 252
Section 40.7: Formatting Numerical Values......Page 253
Section 40.10: Padding and truncating strings, combined......Page 254
Section 40.11: Custom formatting for a class......Page 255
Section 41.1: Changing the capitalization of a string......Page 257
Section 41.2: str.translate: Translating characters in a string......Page 258
Section 41.3: str.format and f-strings: Format values into a string......Page 259
Section 41.4: String module's useful constants......Page 260
Section 41.5: Stripping unwanted leading/trailing characters from a string......Page 261
Section 41.7: Split a string based on a delimiter into a list of strings......Page 262
Section 41.8: Replace all occurrences of one substring with another substring......Page 263
Section 41.9: Testing what a string is composed of......Page 264
Section 41.11: Join a list of strings into one string......Page 266
Section 41.13: Case insensitive string comparisons......Page 267
Section 41.14: Justify strings......Page 268
Section 41.15: Test the starting and ending characters of a string......Page 269
Section 41.16: Conversion between str or bytes data and unicode characters......Page 270
Section 42.1: Return statement inside loop in a function......Page 272
Section 43.1: Importing a module......Page 273
Section 43.2: The __all__ special variable......Page 274
Section 43.4: Importing all names from a module......Page 275
Section 43.6: PEP8 rules for Imports......Page 276
Section 43.9: Re-importing a module......Page 277
Section 43.10: __import__() function......Page 278
Section 44.2: Packages......Page 279
Section 45.1: Rounding: round, floor, ceil, trunc......Page 280
Section 45.2: Trigonometry......Page 281
Section 45.4: Infinity and NaN ("not a number")......Page 282
Section 45.6: Constants......Page 285
Section 45.9: Complex numbers and the cmath module......Page 286
Section 46.1: Advanced complex arithmetic......Page 289
Section 46.2: Basic complex arithmetic......Page 290
Section 47.1: collections.Counter......Page 291
Section 47.2: collections.OrderedDict......Page 292
Section 47.3: collections.defaultdict......Page 293
Section 47.4: collections.namedtuple......Page 294
Section 47.5: collections.deque......Page 295
Section 47.6: collections.ChainMap......Page 296
Section 48.3: Methodcaller......Page 298
Section 49.3: Formatting JSON output......Page 300
Section 49.4: `load` vs `loads`, `dump` vs `dumps`......Page 301
Section 49.6: JSON encoding custom objects......Page 302
Section 49.8: Creating Python dict from JSON......Page 303
Section 50.2: Getting the values from the database and Error handling......Page 304
Section 51.1: makedirs - recursive directory creation......Page 306
Section 51.7: Change permissions on a file......Page 307
Section 52.1: Currency Formatting US Dollars Using the locale Module......Page 308
Section 53.2: itertools.dropwhile......Page 309
Section 53.4: Take a slice of a generator......Page 310
Section 53.5: Grouping items from an iterable object using a function......Page 311
Section 53.7: itertools.permutations......Page 312
Section 53.11: itertools.product......Page 313
Section 53.12: itertools.count......Page 314
Section 53.13: Chaining multiple iterators together......Page 315
Section 54.1: Coroutine and Delegation Syntax......Page 316
Section 54.2: Asynchronous Executors......Page 317
Section 54.4: Synchronization Primitive: Event......Page 318
Section 54.6: Common Misconception about asyncio......Page 319
Section 55.2: Create cryptographically secure random numbers......Page 321
Section 55.3: Random and sequences: shue, choice and sample......Page 322
Section 55.4: Creating random integers and floats: randint, randrange, random, and uniform......Page 323
Section 55.5: Reproducible random numbers: Seed and State......Page 324
Section 55.6: Random Binary Decision......Page 325
Section 56.3: lru_cache......Page 326
Section 56.4: total_ordering......Page 327
Section 56.5: reduce......Page 328
Section 57.3: Disassembling modules......Page 329
Chapter 58: The base64 Module......Page 331
Section 58.1: Encoding and Decoding Base64......Page 332
Section 58.2: Encoding and Decoding Base32......Page 333
Section 58.4: Encoding and Decoding ASCII85......Page 334
Section 58.5: Encoding and Decoding Base85......Page 335
Section 59.1: Simple example......Page 336
Section 60.2: Available methods in deque......Page 337
Section 60.4: Breadth First Search......Page 338
Section 61.1: Opening a URL with Default Browser......Page 339
Section 61.2: Opening a URL with Dierent Browsers......Page 340
Section 62.1: Geometry Managers......Page 341
Section 62.2: A minimal tkinter Application......Page 342
Section 63.3: Screenshot And Image Recognition......Page 344
Section 64.1: Basic Slicing......Page 345
Section 64.4: Making a shallow copy of an array......Page 346
Section 64.5: Indexing custom classes: __getitem__, __setitem__ and __delitem__......Page 347
Section 64.6: Basic Indexing......Page 348
Section 65.1: Plots with Common X-axis but dierent Y-axis : Using twinx()......Page 349
Section 65.2: Plots with common Y-axis and dierent X-axis using twiny()......Page 350
Section 65.3: A Simple Plot in Matplotlib......Page 352
Section 65.4: Adding more features to a simple plot : axis labels, title, axis ticks, grid, and legend......Page 353
Section 65.5: Making multiple plots in the same figure by superimposition similar to MATLAB......Page 354
Section 65.6: Making multiple Plots in the same figure using plot superimposition with separate plot commands......Page 355
Section 66.2: PyGraphviz......Page 357
Section 67.1: Introduction......Page 359
Section 67.2: Infinite sequences......Page 361
Section 67.3: Sending objects to a generator......Page 362
Section 67.6: The next() function......Page 363
Section 67.8: Refactoring list-building code......Page 364
Section 67.9: Yield with recursion: recursively listing all files in a directory......Page 365
Section 67.12: Searching......Page 366
Section 67.13: Iterating over generators in parallel......Page 367
Section 68.2: Using reduce......Page 368
Section 68.4: Non short-circuit variant of any/all......Page 369
Section 69.2: Mapping each value in an iterable......Page 370
Section 69.3: Mapping values of dierent iterables......Page 371
Section 69.5: Series and Parallel Mapping......Page 373
Section 70.2: Square root: math.sqrt() and cmath.sqrt......Page 376
Section 70.4: Computing large integer roots......Page 377
Section 70.5: Exponentiation using the math module: math.pow()......Page 378
Section 70.7: Exponential function minus 1: math.expm1()......Page 379
Section 70.8: Magic methods and exponentiation: builtin, math and cmath......Page 380
Section 70.9: Roots: nth-root with fractional exponents......Page 381
Section 71.2: Searching in custom classes: __contains__ and __iter__......Page 382
Section 71.3: Getting the index for strings: str.index(), str.rindex() and str.find(), str.rfind()......Page 383
Section 71.5: Searching key(s) for a value in dict......Page 384
Section 71.7: Searching nested sequences......Page 385
Section 72.1: Make custom classes orderable......Page 387
Section 72.2: Special case: dictionaries......Page 389
Section 72.4: Default Argument to max, min......Page 390
Section 72.6: Extracting N largest or N smallest items from an iterable......Page 391
Section 72.8: Minimum and Maximum of a sequence......Page 392
Section 73.3: Counting the occurrences of one item in a sequence: list.count() and tuple.count()......Page 393
Section 73.5: Counting occurrences in numpy array......Page 394
Section 74.1: Print basics......Page 395
Section 74.2: Print parameters......Page 396
Section 75.1: Matching the beginning of a string......Page 398
Section 75.3: Precompiled patterns......Page 399
Section 75.4: Flags......Page 400
Section 75.6: Find All Non-Overlapping Matches......Page 401
Section 75.9: Grouping......Page 402
Section 75.10: Escaping Special Characters......Page 403
Section 75.11: Match an expression only in specific locations......Page 404
Section 75.12: Iterating over matches using `re.finditer`......Page 405
Section 76.5: Copy a set......Page 406
Section 77.2: Writing your own context manager......Page 408
Section 77.3: Writing your own contextmanager using generator syntax......Page 409
Section 77.5: Assigning to a target......Page 410
Section 77.6: Manage Resources......Page 411
Section 78.3: function_class_or_module.__name__......Page 412
Section 79.1: Perform checks using os.access......Page 414
Section 80.2: Uploading to PyPI......Page 415
Section 80.3: Making package executable......Page 417
Section 81.2: Handling ImportError Exception......Page 419
Section 81.3: Force install......Page 420
Section 82.3: Upgrade Packages......Page 421
Section 82.7: Create a requirements.txt file of all packages on the system......Page 422
Section 82.9: Create a requirements.txt file of packages only in the current virtualenv......Page 423
Section 82.10: Installing packages not yet on pip as wheels......Page 424
Section 83.2: Using command line arguments with argv......Page 427
Section 83.3: Setting mutually exclusive arguments with argparse......Page 428
Section 83.5: Custom parser error message with argparse......Page 429
Section 83.6: Conceptual grouping of arguments with argparse.add_argument_group()......Page 430
Section 83.7: Advanced example with docopt and docopt_dispatch......Page 431
Section 84.1: More flexibility with Popen......Page 433
Section 84.3: How to create the command list argument......Page 434
Section 85.2: Using source control metadata in setup.py......Page 435
Section 85.4: Adding installation options......Page 436
Section 86.1: The What, How, and When of Recursion......Page 438
Section 86.2: Tree exploration with recursion......Page 441
Section 86.4: Increasing the Maximum Recursion Depth......Page 442
Section 86.6: Tail Recursion Optimization Through Stack Introspection......Page 443
Section 87.1: Adding types to a function......Page 445
Section 87.4: Variables and Attributes......Page 446
Section 87.6: Type hints for keyword arguments......Page 447
Section 88.2: Do not catch everything!......Page 448
Section 88.4: Catching multiple exceptions......Page 449
Section 88.5: Exception Hierarchy......Page 450
Section 88.7: Raising Exceptions......Page 452
Section 88.9: Practical examples of exception handling......Page 453
Section 88.11: Running clean-up code with finally......Page 454
Section 88.12: Chain exceptions with raise from......Page 455
Section 89.2: Catch custom Exception......Page 456
Section 90.1: Other Errors......Page 457
Section 90.2: NameError: name '???' is not defined......Page 458
Section 90.3: TypeErrors......Page 459
Section 90.4: Syntax Error on good code......Page 460
Section 90.5: IndentationErrors (or indentation SyntaxErrors)......Page 461
Section 91.2: HTTP POST......Page 463
Section 91.3: Decode received bytes according to content type encoding......Page 464
Section 92.2: Scraping using Selenium WebDriver......Page 465
Section 92.4: Maintaining web-scraping session with requests......Page 466
Section 92.8: Scraping with curl......Page 467
Section 93.2: PyQuery......Page 469
Section 93.3: Locate a text after an element in BeautifulSoup......Page 470
Section 94.2: Create and Build XML Documents......Page 471
Section 94.4: Searching the XML with XPath......Page 472
Section 94.5: Opening and reading large XML files using iterparse (incremental parsing)......Page 473
Section 95.1: Simple Post......Page 474
Section 95.3: File Upload......Page 475
Section 95.5: Authentication......Page 476
Section 95.6: Proxies......Page 477
Section 96.1: py2app......Page 479
Section 96.2: cx_Freeze......Page 480
Section 97.2: Using the @property decorator......Page 481
Section 97.4: Using properties without decorators......Page 482
Section 98.1: Operator overloading......Page 485
Section 98.2: Magic/Dunder Methods......Page 486
Section 98.3: Container and sequence types......Page 487
Section 98.5: Handling unimplemented behaviour......Page 488
Section 99.2: Basic Polymorphism......Page 490
Section 100.1: Basic method overriding......Page 493
Section 101.1: Creating user-defined method objects......Page 494
Section 101.2: Turtle example......Page 495
Section 102.1: Motivation......Page 496
Section 102.2: Both methods implemented, eval-round-trip style __repr__()......Page 500
Section 103.2: The Python Debugger: Step-through Debugging with _pdb_......Page 501
Section 103.3: Remote debugger......Page 503
Section 104.2: Writing a TSV file......Page 504
Section 105.2: Appending a String as a newline in a CSV file......Page 505
Section 106.3: Evaluating statements with exec......Page 506
Section 106.6: Evaluating an expression with eval using custom globals......Page 507
Section 107.2: Using Pyinstaller......Page 508
Section 107.4: Bundling to a Single File......Page 509
Section 108.1: Seaborn......Page 510
Section 108.2: Matplotlib......Page 512
Section 108.3: Plotly......Page 513
Section 108.4: MayaVI......Page 515
Section 109.2: Referring to the last expression......Page 517
Section 109.5: Command line arguments......Page 518
Section 109.6: Getting help about an object......Page 519
Section 110.2: Using *args when writing functions......Page 521
Section 110.6: **kwargs and default values......Page 522
Section 110.7: Using *args when calling functions......Page 523
Section 111.2: Eects of the del command......Page 524
Section 111.4: Garbage Collector for Reference Cycles......Page 525
Section 111.5: Forcefully deallocating objects......Page 526
Section 111.8: Managing garbage collection......Page 527
Section 112.2: Customize Pickled Data......Page 529
Section 113.3: Packing a structure......Page 531
Section 114.3: Use truth value testing......Page 533
Section 114.4: Test for "__main__" to avoid unexpected code execution......Page 534
Section 115.2: Serialization using Pickle......Page 535
Section 116.2: Using Pool and Map......Page 537
Section 117.1: Basics of multithreading......Page 539
Section 117.2: Communicating between threads......Page 540
Section 117.4: Advanced use of multithreads......Page 541
Section 117.5: Stoppable Thread with a while Loop......Page 543
Section 118.1: Global Interpreter Lock......Page 544
Section 118.2: Running in Multiple Threads......Page 545
Section 118.4: Sharing State Between Threads......Page 546
Section 118.5: Sharing State Between Processes......Page 547
Section 119.1: The multiprocessing module......Page 548
Section 119.3: Passing data between multiprocessing processes......Page 549
Section 120.3: Using Parent and Children scripts to execute code in parallel......Page 551
Section 120.4: Using PyPar module to parallelize......Page 552
Section 121.2: Sending data via UDP......Page 553
Section 121.5: Multi-threaded TCP Socket Server......Page 554
Section 122.2: Wrapper Class with aiohttp......Page 557
Section 122.3: Using Autobahn as a Websocket Factory......Page 558
Section 123.1: Server side Implementation......Page 560
Section 123.2: Client side Implementation......Page 562
Section 124.2: Creating a TCP server......Page 564
Section 124.4: Start Simple HttpServer in a thread and open the browser......Page 565
Section 124.5: The simplest Python socket client-server example......Page 566
Section 125.2: Serving files......Page 567
Section 125.3: Basic handling of GET, POST, PUT using BaseHTTPRequestHandler......Page 568
Section 125.4: Programmatic API of SimpleHTTPServer......Page 569
Section 126.2: The basics......Page 571
Section 126.3: Routing URLs......Page 572
Section 126.5: Jinja Templating......Page 573
Section 126.6: The Request Object......Page 574
Section 127.1: How to consume messages from RabbitMQ......Page 576
Section 127.3: How to create a delayed queue in RabbitMQ......Page 577
Section 128.1: Simple descriptor......Page 580
Section 128.2: Two-way conversions......Page 581
Section 129.1: Create (and write to a) known, persistent temporary file......Page 582
Section 130.1: Basic Code to Import, Subset and Write External Data Files Using Pandas......Page 583
Section 131.2: Using Python TarFile.extractall() to decompress a tarball......Page 585
Section 132.2: Opening Zip Files......Page 586
Section 132.4: Creating new archives......Page 587
Section 133.1: Read and write GNU zip files......Page 588
Section 134.1: Creating a Stack class with a List Object......Page 589
Section 134.2: Parsing Parentheses......Page 590
Section 135.1: Multiprocessing.Pool......Page 591
Section 135.2: Cython nogil:......Page 592
Section 136.1: Uploading a Conda Package......Page 593
Section 137.1: Introduction to Python Logging......Page 595
Section 137.2: Logging exceptions......Page 596
Section 138.1: Server Object (Method)......Page 599
Section 139.2: Asyncio SSE......Page 600
Section 140.2: Use a dict of functions......Page 601
Section 140.3: Use class introspection......Page 602
Section 140.4: Using a context manager......Page 603
Section 141.1: Destructuring assignment......Page 604
Section 141.2: Packing function arguments......Page 605
Section 141.3: Unpacking function arguments......Page 607
Section 142.2: Display the source code of an object......Page 608
Section 142.3: Exploring the code object of a function......Page 609
Section 143.1: Mixin......Page 610
Section 143.2: Overriding Methods in Mixins......Page 611
Section 144.2: Setters, Getters & Properties......Page 612
Section 145.2: Printing one field's value for all rows of feature class in file geodatabase using Search Cursor......Page 614
Section 146.2: Why/How to use ABCMeta and @abstractmethod......Page 615
Section 147.1: Mixins......Page 617
Section 147.2: Plugins with Customized Classes......Page 618
Section 148.3: Frozenset's are immutable and not assignable......Page 620
Section 149.1: Integer Division......Page 621
Section 149.2: Unpacking Iterables......Page 622
Section 149.3: Strings: Bytes versus Unicode......Page 624
Section 149.4: Print statement vs. Print function......Page 626
Section 149.5: Dierences between range and xrange functions......Page 627
Section 149.6: Raising and handling Exceptions......Page 628
Section 149.7: Leaked variables in list comprehension......Page 630
Section 149.9: User Input......Page 631
Section 149.11: .next() method on iterators renamed......Page 632
Section 149.13: Renamed modules......Page 633
Section 149.15: long vs. int......Page 634
Section 149.16: All classes are "new-style classes" in Python 3......Page 635
Section 149.18: Absolute/Relative Imports......Page 636
Section 149.19: map()......Page 638
Section 149.20: The round() function tie-breaking and return type......Page 639
Section 149.22: cmp function removed in Python 3......Page 640
Section 149.25: exec statement is a function in Python 3......Page 641
Section 149.26: encode/decode to hex no longer available......Page 642
Section 149.28: Class Boolean Value......Page 643
Section 149.29: hasattr function bug in Python 2......Page 644
Section 150.1: Basic Usage......Page 645
Section 151.2: Jython......Page 647
Section 151.3: Transcrypt......Page 648
Section 152.1: Analyze functions in a python script......Page 651
Section 153.2: File I/O......Page 653
Section 153.3: Basics......Page 654
Section 154.3: Check what serial ports are available on your machine......Page 656
Section 155.4: Query 1 : Autocomplete on News Titles......Page 658
Section 155.6: Cypher Query Samples......Page 659
Section 156.2: Basic Invocation Example......Page 660
Section 157.2: Changing delimiter......Page 661
Section 158.2: Convert files to JPEG......Page 662
Section 159.2: Create a new Exception that can be caught......Page 663
Section 160.2: argparse (default help formatter)......Page 664
Section 160.3: argparse (custom help formatter)......Page 665
Section 161.1: SQLite......Page 667
Section 161.2: Accessing MySQL database using MySQLdb......Page 672
Section 161.3: Connection......Page 673
Section 161.4: PostgreSQL Database access using psycopg2......Page 674
Section 161.5: Oracle database......Page 675
Section 161.6: Using sqlalchemy......Page 677
Section 162.1: Connect to Server, Create Table, Query Data......Page 678
Section 163.1: Getting Started......Page 679
Section 164.2: Format Excel files with xlsxwriter......Page 680
Section 164.3: Put list data into a Excel's file......Page 681
Section 164.5: Create excel charts with xlsxwriter......Page 682
Section 165.1: Ninja Twist (Turtle Graphics)......Page 685
Section 166.1: Python Persistence......Page 686
Section 166.2: Function utility for save and load......Page 687
Section 167.1: Introduction to design patterns and Singleton Pattern......Page 688
Section 167.2: Strategy Pattern......Page 690
Section 167.3: Proxy......Page 691
Section 168.1: MD5 hash of a string......Page 693
Section 168.2: algorithm provided by OpenSSL......Page 694
Section 169.1: A Python script that can be run as a service......Page 695
Section 169.2: Running a Flask web application as a service......Page 696
Section 170.1: Mutable vs Immutable......Page 697
Section 170.2: Mutable and Immutable as Arguments......Page 699
Section 171.2: Basic usage......Page 701
Section 172.2: PyOCR......Page 702
Section 173.1: Creating and using a virtual environment......Page 704
Section 173.4: Making virtual environments using Anaconda......Page 706
Section 173.5: Managing multiple virtual environments with virtualenvwrapper......Page 707
Section 173.6: Installing packages in a virtual environment......Page 708
Section 173.7: Discovering which virtual environment you are using......Page 709
Section 173.9: Using virtualenv with fish shell......Page 710
Section 174.3: Install a package in your Virtualenv......Page 712
Section 174.4: Other useful virtualenv commands......Page 713
Section 175.1: Create virtual environment with virtualenvwrapper......Page 714
Section 176.1: Virtual environment with virtualenvwrapper for windows......Page 716
Section 177.4: Ending the process prematurely and returning an exit code......Page 717
Section 178.3: Balancing reactions......Page 718
Section 178.6: Chemical kinetics (system of ordinary dierential equations)......Page 719
Section 179.1: Pygame's mixer module......Page 721
Section 179.2: Installing pygame......Page 722
Section 180.5: Drawing Points Using Pyglet and OpenGL......Page 723
Section 181.3: Playing Windows' beeps......Page 725
Section 181.4: Audio With Pyglet......Page 726
Section 182.1: Callback Mode Audio I/O......Page 727
Section 182.2: Blocking Mode Audio I/O......Page 728
Section 183.1: Creating a new Shelf......Page 730
Section 183.4: Write-back......Page 731
Section 184.1: Example - Temperature sensor......Page 733
Section 185.1: First App......Page 736
Section 186.1: Simple transform......Page 738
Section 186.2: Multiple results per group......Page 739
Section 187.1: `in` with lists......Page 740
Section 188.2: C# code calling Python script......Page 741
Section 189.2: Wrapping functions for ctypes......Page 743
Section 189.4: Common pitfalls......Page 744
Section 189.5: Basic ctypes object......Page 745
Section 189.6: Complex usage......Page 746
Section 190.2: C Extension Using c++ and Boost......Page 747
Section 190.3: Passing an open file to C Extensions......Page 749
Section 191.2: The "Hello, World!" of PLY - A Simple Calculator......Page 750
Section 191.3: Part 1: Tokenizing Input with Lex......Page 752
Section 191.4: Part 2: Parsing Tokenized Input with Yacc......Page 755
Section 192.2: Asserting on Exceptions......Page 759
Section 192.3: Testing Exceptions......Page 760
Section 192.4: Choosing Assertions Within Unittests......Page 761
Section 192.5: Unit tests with pytest......Page 762
Section 192.6: Mocking functions with unittest.mock.create_autospec......Page 765
Section 193.2: Intro to Test Fixtures......Page 767
Section 193.3: Failing Tests......Page 770
Section 194.3: timeit() function......Page 772
Section 194.5: line_profiler in command line......Page 773
Section 195.2: Algorithmic Notations......Page 774
Section 195.3: Notation......Page 775
Section 195.5: Set operations......Page 776
Section 196.1: Code profiling......Page 778
Section 197.3: Available Hashing Algorithms......Page 780
Section 197.5: Generating RSA signatures using pycrypto......Page 781
Section 197.6: Asymmetric RSA encryption using pycrypto......Page 782
Section 197.7: Symmetric encryption using pycrypto......Page 783
Section 198.1: ssh connection......Page 784
Section 199.2: Looking before you leap with processor-intensive function......Page 785
Section 200.1: List multiplication and common references......Page 787
Section 200.2: Mutable default argument......Page 790
Section 200.3: Changing the sequence you are iterating over......Page 791
Section 200.4: Integer and String identity......Page 794
Section 200.5: Dictionaries are unordered......Page 795
Section 200.7: Chaining of or operator......Page 796
Section 200.9: Accessing int literals' attributes......Page 797
Section 200.10: Global Interpreter Lock (GIL) and blocking threads......Page 798
Section 200.12: Pythonic JSON keys......Page 799
Section 201.1: Operator Overloading......Page 801
Credits......Page 802
You may also like......Page 816