Python® Notes for Professionals
Free
Description
Contents
Reviews
Language
English
ISBN
Unknown
Content list
About
Chapter 1: Getting started with Python Language
Section 1.1: Getting Started
Section 1.2: Creating variables and assigning values
Section 1.3: Block Indentation
Section 1.4: Datatypes
Section 1.5: Collection Types
Section 1.6: IDLE - Python GUI
Section 1.7: User Input
Section 1.8: Built in Modules and Functions
Section 1.9: Creating a module
Section 1.10: Installation of Python 2.7.x and 3.x
Section 1.11: String function - str() and repr()
Section 1.12: Installing external modules using pip
Section 1.13: Help Utility
Chapter 2: Python Data Types
Section 2.1: String Data Type
Section 2.2: Set Data Types
Section 2.3: Numbers data type
Section 2.4: List Data Type
Section 2.5: Dictionary Data Type
Section 2.6: Tuple Data Type
Chapter 3: Indentation
Section 3.1: Simple example
Section 3.2: How Indentation is Parsed
Section 3.3: Indentation Errors
Chapter 4: Comments and Documentation
Section 4.1: Single line, inline and multiline comments
Section 4.2: Programmatically accessing docstrings
Section 4.3: Write documentation using docstrings
Chapter 5: Date and Time
Section 5.1: Parsing a string into a timezone aware datetime object
Section 5.2: Constructing timezone-aware datetimes
Section 5.3: Computing time dierences
Section 5.4: Basic datetime objects usage
Section 5.5: Switching between time zones
Section 5.6: Simple date arithmetic
Section 5.7: Converting timestamp to datetime
Section 5.8: Subtracting months from a date accurately
Section 5.9: Parsing an arbitrary ISO 8601 timestamp with minimal libraries
Section 5.10: Get an ISO 8601 timestamp
Section 5.11: Parsing a string with a short time zone name into a timezone aware datetime object
Section 5.12: Fuzzy datetime parsing (extracting datetime out of a text)
Section 5.13: Iterate over dates
Chapter 6: Date Formatting
Section 6.1: Time between two date-times
Section 6.2: Outputting datetime object to string
Section 6.3: Parsing string to datetime object
Chapter 7: Enum
Section 7.1: Creating an enum (Python 2.4 through 3.3)
Section 7.2: Iteration
Chapter 8: Set
Section 8.1: Operations on sets
Section 8.2: Get the unique elements of a list
Section 8.3: Set of Sets
Section 8.4: Set Operations using Methods and Builtins
Section 8.5: Sets versus multisets
Chapter 9: List comprehensions
Section 9.1: List Comprehensions
Section 9.2: Avoid repetitive and expensive operations using conditional clause
Section 9.3: Dictionary Comprehensions
Section 9.4: Generator Expressions
Section 9.5: Set Comprehensions
Section 9.6: Comprehensions involving tuples
Section 9.7: Counting Occurrences Using Comprehension
Section 9.8: Changing Types in a List
Chapter 10: Simple Mathematical Operators
Section 10.1: Division
Section 10.2: Addition
Section 10.3: Exponentation
Section 10.4: Trigonometric Functions
Section 10.5: Inplace Operations
Section 10.6: Subtraction
Section 10.7: Multiplication
Section 10.8: Logarithms
Section 10.9: Modulus
Chapter 11: Bitwise Operators
Section 11.1: Bitwise NOT
Section 11.2: Bitwise XOR (Exclusive OR)
Section 11.3: Bitwise AND
Section 11.4: Bitwise OR
Section 11.5: Bitwise Left Shift
Section 11.6: Bitwise Right Shift
Section 11.7: Inplace Operations
Chapter 12: Boolean Operators
Section 12.1: `and` and `or` are not guaranteed to return a boolean
Section 12.2: A simple example
Section 12.3: Short-circuit evaluation
Section 12.4: and
Section 12.5: or
Section 12.6: not
Chapter 13: Operator Precedence
Section 13.1: Simple Operator Precedence Examples in python
Chapter 14: Filter
Section 14.1: Basic use of filter
Section 14.2: Filter without function
Section 14.3: Filter as short-circuit check
Section 14.4: Complementary function: filterfalse, ifilterfalse
Chapter 15: Arrays
Section 15.1: Access individual elements through indexes
Section 15.2: Basic Introduction to Arrays
Section 15.3: Append any value to the array using append() method
Section 15.4: Insert value in an array using insert() method
Section 15.5: Extend python array using extend() method
Section 15.6: Add items from list into array using fromlist() method
Section 15.7: Remove any array element using remove() method
Section 15.8: Remove last array element using pop() method
Section 15.9: Fetch any element through its index using index() method
Section 15.10: Reverse a python array using reverse() method
Section 15.11: Get array buer information through buer_info() method
Section 15.12: Check for number of occurrences of an element using count() method
Section 15.13: Convert array to string using tostring() method
Section 15.14: Convert array to a python list with same elements using tolist() method
Section 15.15: Append a string to char array using fromstring() method
Chapter 16: Dictionary
Section 16.1: Introduction to Dictionary
Section 16.2: Avoiding KeyError Exceptions
Section 16.3: Iterating Over a Dictionary
Section 16.4: Dictionary with default values
Section 16.5: Merging dictionaries
Section 16.6: Accessing keys and values
Section 16.7: Accessing values of a dictionary
Section 16.8: Creating a dictionary
Section 16.9: Creating an ordered dictionary
Section 16.10: Unpacking dictionaries using the ** operator
Section 16.11: The trailing comma
Section 16.12: The dict() constructor
Section 16.13: Dictionaries Example
Section 16.14: All combinations of dictionary values
Chapter 17: List
Section 17.1: List methods and supported operators
Section 17.2: Accessing list values
Section 17.3: Checking if list is empty
Section 17.4: Iterating over a list
Section 17.5: Checking whether an item is in a list
Section 17.6: Any and All
Section 17.7: Reversing list elements
Section 17.8: Concatenate and Merge lists
Section 17.9: Length of a list
Section 17.10: Remove duplicate values in list
Section 17.11: Comparison of lists
Section 17.12: Accessing values in nested list
Section 17.13: Initializing a List to a Fixed Number of Elements
Chapter 18: List slicing (selecting parts of lists)
Section 18.1: Using the third "step" argument
Section 18.2: Selecting a sublist from a list
Section 18.3: Reversing a list with slicing
Section 18.4: Shifting a list using slicing
Chapter 19: Linked lists
Section 19.1: Single linked list example
Chapter 20: Linked List Node
Section 20.1: Write a simple Linked List Node in python
Chapter 21: Tuple
Section 21.1: Tuple
Section 21.2: Tuples are immutable
Section 21.3: Packing and Unpacking Tuples
Section 21.4: Built-in Tuple Functions
Section 21.5: Tuple Are Element-wise Hashable and Equatable
Section 21.6: Indexing Tuples
Section 21.7: Reversing Elements
Chapter 22: Functions
Section 22.1: Defining and calling simple functions
Section 22.2: Defining a function with an arbitrary number of arguments
Section 22.3: Lambda (Inline/Anonymous) Functions
Section 22.4: Defining a function with optional arguments
Section 22.5: Defining a function with optional mutable arguments
Section 22.6: Argument passing and mutability
Section 22.7: Returning values from functions
Section 22.8: Closure
Section 22.9: Forcing the use of named parameters
Section 22.10: Nested functions
Section 22.11: Recursion limit
Section 22.12: Recursive Lambda using assigned variable
Section 22.13: Recursive functions
Section 22.14: Defining a function with arguments
Section 22.15: Iterable and dictionary unpacking
Section 22.16: Defining a function with multiple arguments
Chapter 23: Defining functions with list arguments
Section 23.1: Function and Call
Chapter 24: Functional Programming in Python
Section 24.1: Lambda Function
Section 24.2: Map Function
Section 24.3: Reduce Function
Section 24.4: Filter Function
Chapter 25: Partial functions
Section 25.1: Raise the power
Chapter 26: Decorators
Section 26.1: Decorator function
Section 26.2: Decorator class
Section 26.3: Decorator with arguments (decorator factory)
Section 26.4: Making a decorator look like the decorated function
Section 26.5: Using a decorator to time a function
Section 26.6: Create singleton class with a decorator
Chapter 27: Classes
Section 27.1: Introduction to classes
Section 27.2: Bound, unbound, and static methods
Section 27.3: Basic inheritance
Section 27.4: Monkey Patching
Section 27.5: New-style vs. old-style classes
Section 27.6: Class methods: alternate initializers
Section 27.7: Multiple Inheritance
Section 27.8: Properties
Section 27.9: Default values for instance variables
Section 27.10: Class and instance variables
Section 27.11: Class composition
Section 27.12: Listing All Class Members
Section 27.13: Singleton class
Section 27.14: Descriptors and Dotted Lookups
Chapter 28: Metaclasses
Section 28.1: Basic Metaclasses
Section 28.2: Singletons using metaclasses
Section 28.3: Using a metaclass
Section 28.4: Introduction to Metaclasses
Section 28.5: Custom functionality with metaclasses
Section 28.6: The default metaclass
Chapter 29: String Methods
Section 29.1: Changing the capitalization of a string
Section 29.2: str.translate: Translating characters in a string
Section 29.3: str.format and f-strings: Format values into a string
Section 29.4: String module's useful constants
Section 29.5: Stripping unwanted leading/trailing characters from a string
Section 29.6: Reversing a string
Section 29.7: Split a string based on a delimiter into a list of strings
Section 29.8: Replace all occurrences of one substring with another substring
Section 29.9: Testing what a string is composed of
Section 29.10: String Contains
Section 29.11: Join a list of strings into one string
Section 29.12: Counting number of times a substring appears in a string
Section 29.13: Case insensitive string comparisons
Section 29.14: Justify strings
Section 29.15: Test the starting and ending characters of a string
Section 29.16: Conversion between str or bytes data and unicode characters
Chapter 30: String Formatting
Section 30.1: Basics of String Formatting
Section 30.2: Alignment and padding
Section 30.3: Format literals (f-string)
Section 30.4: Float formatting
Section 30.5: Named placeholders
Section 30.6: String formatting with datetime
Section 30.7: Formatting Numerical Values
Section 30.8: Nested formatting
Section 30.9: Format using Getitem and Getattr
Section 30.10: Padding and truncating strings, combined
Section 30.11: Custom formatting for a class
Chapter 31: Conditionals
Section 31.1: Conditional Expression (or "The Ternary Operator")
Section 31.2: if, elif, and else
Section 31.3: Truth Values
Section 31.4: Boolean Logic Expressions
Section 31.5: Using the cmp function to get the comparison result of two objects
Section 31.6: Else statement
Section 31.7: Testing if an object is None and assigning it
Section 31.8: If statement
Chapter 32: Loops
Section 32.1: Break and Continue in Loops
Section 32.2: For loops
Section 32.3: Iterating over lists
Section 32.4: Loops with an "else" clause
Section 32.5: The Pass Statement
Section 32.6: Iterating over dictionaries
Section 32.7: The "half loop" do-while
Section 32.8: Looping and Unpacking
Section 32.9: Iterating dierent portion of a list with dierent step size
Section 32.10: While Loop
Chapter 33: Using loops within functions
Section 33.1: Return statement inside loop in a function
Chapter 34: Importing modules
Section 34.1: Importing a module
Section 34.2: The __all__ special variable
Section 34.3: Import modules from an arbitrary filesystem location
Section 34.4: Importing all names from a module
Section 34.5: Programmatic importing
Section 34.6: PEP8 rules for Imports
Section 34.7: Importing specific names from a module
Section 34.8: Importing submodules
Section 34.9: Re-importing a module
Section 34.10: __import__() function
Chapter 35: Dierence between Module and Package
Section 35.1: Modules
Section 35.2: Packages
Chapter 36: Math Module
Section 36.1: Rounding: round, floor, ceil, trunc
Section 36.2: Trigonometry
Section 36.3: Pow for faster exponentiation
Section 36.4: Infinity and NaN ("not a number")
Section 36.5: Logarithms
Section 36.6: Constants
Section 36.7: Imaginary Numbers
Section 36.8: Copying signs
Section 36.9: Complex numbers and the cmath module
Chapter 37: Complex math
Section 37.1: Advanced complex arithmetic
Section 37.2: Basic complex arithmetic
Chapter 38: Collections module
Section 38.1: collections.Counter
Section 38.2: collections.OrderedDict
Section 38.3: collections.defaultdict
Section 38.4: collections.namedtuple
Section 38.5: collections.deque
Section 38.6: collections.ChainMap
Chapter 39: Operator module
Section 39.1: Itemgetter
Section 39.2: Operators as alternative to an infix operator
Section 39.3: Methodcaller
Chapter 40: JSON Module
Section 40.1: Storing data in a file
Section 40.2: Retrieving data from a file
Section 40.3: Formatting JSON output
Section 40.4: `load` vs `loads`, `dump` vs `dumps`
Section 40.5: Calling `json.tool` from the command line to pretty-print JSON output
Section 40.6: JSON encoding custom objects
Section 40.7: Creating JSON from Python dict
Section 40.8: Creating Python dict from JSON
Chapter 41: Sqlite3 Module
Section 41.1: Sqlite3 - Not require separate server process
Section 41.2: Getting the values from the database and Error handling
Chapter 42: The os Module
Section 42.1: makedirs - recursive directory creation
Section 42.2: Create a directory
Section 42.3: Get current directory
Section 42.4: Determine the name of the operating system
Section 42.5: Remove a directory
Section 42.6: Follow a symlink (POSIX)
Section 42.7: Change permissions on a file
Chapter 43: The locale Module
Section 43.1: Currency Formatting US Dollars Using the locale Module
Chapter 44: Itertools Module
Section 44.1: Combinations method in Itertools Module
Section 44.2: itertools.dropwhile
Section 44.3: Zipping two iterators until they are both exhausted
Section 44.4: Take a slice of a generator
Section 44.5: Grouping items from an iterable object using a function
Section 44.6: itertools.takewhile
Section 44.7: itertools.permutations
Section 44.8: itertools.repeat
Section 44.9: Get an accumulated sum of numbers in an iterable
Section 44.10: Cycle through elements in an iterator
Section 44.11: itertools.product
Section 44.12: itertools.count
Section 44.13: Chaining multiple iterators together
Chapter 45: Asyncio Module
Section 45.1: Coroutine and Delegation Syntax
Section 45.2: Asynchronous Executors
Section 45.3: Using UVLoop
Section 45.4: Synchronization Primitive: Event
Section 45.5: A Simple Websocket
Section 45.6: Common Misconception about asyncio
Chapter 46: Random module
Section 46.1: Creating a random user password
Section 46.2: Create cryptographically secure random numbers
Section 46.3: Random and sequences: shue, choice and sample
Section 46.4: Creating random integers and floats: randint, randrange, random, and uniform
Section 46.5: Reproducible random numbers: Seed and State
Section 46.6: Random Binary Decision
Chapter 47: Functools Module
Section 47.1: partial
Section 47.2: cmp_to_key
Section 47.3: lru_cache
Section 47.4: total_ordering
Section 47.5: reduce
Chapter 48: The dis module
Section 48.1: What is Python bytecode?
Section 48.2: Constants in the dis module
Section 48.3: Disassembling modules
Chapter 49: The base64 Module
Section 49.1: Encoding and Decoding Base64
Section 49.2: Encoding and Decoding Base32
Section 49.3: Encoding and Decoding Base16
Section 49.4: Encoding and Decoding ASCII85
Section 49.5: Encoding and Decoding Base85
Chapter 50: Queue Module
Section 50.1: Simple example
Chapter 51: Deque Module
Section 51.1: Basic deque using
Section 51.2: Available methods in deque
Section 51.3: limit deque size
Section 51.4: Breadth First Search
Chapter 52: Usage of "pip" module: PyPI Package Manager
Section 52.1: Example use of commands
Section 52.2: Handling ImportError Exception
Section 52.3: Force install
Chapter 53: Webbrowser Module
Section 53.1: Opening a URL with Default Browser
Section 53.2: Opening a URL with Dierent Browsers
Chapter 54: pyautogui module
Section 54.1: Mouse Functions
Section 54.2: Keyboard Functions
Section 54.3: ScreenShot And Image Recognition
Chapter 55: Plotting with Matplotlib
Section 55.1: Plots with Common X-axis but dierent Y-axis : Using twinx()
Section 55.2: Plots with common Y-axis and dierent X-axis using twiny()
Section 55.3: A Simple Plot in Matplotlib
Section 55.4: Adding more features to a simple plot : axis labels, title, axis ticks, grid, and legend
Section 55.5: Making multiple plots in the same figure by superimposition similar to MATLAB
Section 55.6: Making multiple Plots in the same figure using plot superimposition with separate plot commands
Chapter 56: Comparisons
Section 56.1: Chain Comparisons
Section 56.2: Comparison by `is` vs `==`
Section 56.3: Greater than or less than
Section 56.4: Not equal to
Section 56.5: Equal To
Section 56.6: Comparing Objects
Chapter 57: Sorting, Minimum and Maximum
Section 57.1: Make custom classes orderable
Section 57.2: Special case: dictionaries
Section 57.3: Using the key argument
Section 57.4: Default Argument to max, min
Section 57.5: Getting a sorted sequence
Section 57.6: Extracting N largest or N smallest items from an iterable
Section 57.7: Getting the minimum or maximum of several values
Section 57.8: Minimum and Maximum of a sequence
Chapter 58: Variable Scope and Binding
Section 58.1: Nonlocal Variables
Section 58.2: Global Variables
Section 58.3: Local Variables
Section 58.4: The del command
Section 58.5: Functions skip class scope when looking up names
Section 58.6: Local vs Global Scope
Section 58.7: Binding Occurrence
Chapter 59: Basic Input and Output
Section 59.1: Using the print function
Section 59.2: Input from a File
Section 59.3: Read from stdin
Section 59.4: Using input() and raw_input()
Section 59.5: Function to prompt user for a number
Section 59.6: Printing a string without a newline at the end
Chapter 60: Files & Folders I/O
Section 60.1: File modes
Section 60.2: Reading a file line-by-line
Section 60.3: Iterate files (recursively)
Section 60.4: Getting the full contents of a file
Section 60.5: Writing to a file
Section 60.6: Check whether a file or path exists
Section 60.7: Random File Access Using mmap
Section 60.8: Replacing text in a file
Section 60.9: Checking if a file is empty
Section 60.10: Read a file between a range of lines
Section 60.11: Copy a directory tree
Section 60.12: Copying contents of one file to a dierent file
Chapter 61: Indexing and Slicing
Section 61.1: Basic Slicing
Section 61.2: Reversing an object
Section 61.3: Slice assignment
Section 61.4: Making a shallow copy of an array
Section 61.5: Indexing custom classes: __getitem__, __setitem__ and __delitem__
Section 61.6: Basic Indexing
Chapter 62: Generators
Section 62.1: Introduction
Section 62.2: Infinite sequences
Section 62.3: Sending objects to a generator
Section 62.4: Yielding all values from another iterable
Section 62.5: Iteration
Section 62.6: The next() function
Section 62.7: Coroutines
Section 62.8: Refactoring list-building code
Section 62.9: Yield with recursion: recursively listing all files in a directory
Section 62.10: Generator expressions
Section 62.11: Using a generator to find Fibonacci Numbers
Section 62.12: Searching
Section 62.13: Iterating over generators in parallel
Chapter 63: Reduce
Section 63.1: Overview
Section 63.2: Using reduce
Section 63.3: Cumulative product
Section 63.4: Non short-circuit variant of any/all
Chapter 64: Map Function
Section 64.1: Basic use of map, itertools.imap and future_builtins.map
Section 64.2: Mapping each value in an iterable
Section 64.3: Mapping values of dierent iterables
Section 64.4: Transposing with Map: Using "None" as function argument (python 2.x only)
Section 64.5: Series and Parallel Mapping
Chapter 65: Exponentiation
Section 65.1: Exponentiation using builtins: ** and pow()
Section 65.2: Square root: math.sqrt() and cmath.sqrt
Section 65.3: Modular exponentiation: pow() with 3 arguments
Section 65.4: Computing large integer roots
Section 65.5: Exponentiation using the math module: math.pow()
Section 65.6: Exponential function: math.exp() and cmath.exp()
Section 65.7: Exponential function minus 1: math.expm1()
Section 65.8: Magic methods and exponentiation: builtin, math and cmath
Section 65.9: Roots: nth-root with fractional exponents
Chapter 66: Searching
Section 66.1: Searching for an element
Section 66.2: Searching in custom classes: __contains__ and __iter__
Section 66.3: Getting the index for strings: str.index(), str.rindex() and str.find(), str.rfind()
Section 66.4: Getting the index list and tuples: list.index(), tuple.index()
Section 66.5: Searching key(s) for a value in dict
Section 66.6: Getting the index for sorted sequences: bisect.bisect_left()
Section 66.7: Searching nested sequences
Chapter 67: Counting
Section 67.1: Counting all occurence of all items in an iterable: collections.Counter
Section 67.2: Getting the most common value(-s): collections.Counter.most_common()
Section 67.3: Counting the occurrences of one item in a sequence: list.count() and tuple.count()
Section 67.4: Counting the occurrences of a substring in a string: str.count()
Section 67.5: Counting occurences in numpy array
Chapter 68: Manipulating XML
Section 68.1: Opening and reading using an ElementTree
Section 68.2: Create and Build XML Documents
Section 68.3: Modifying an XML File
Section 68.4: Searching the XML with XPath
Section 68.5: Opening and reading large XML files using iterparse (incremental parsing)
Chapter 69: Parallel computation
Section 69.1: Using the multiprocessing module to parallelise tasks
Section 69.2: Using a C-extension to parallelize tasks
Section 69.3: Using Parent and Children scripts to execute code in parallel
Section 69.4: Using PyPar module to parallelize
Chapter 70: Processes and Threads
Section 70.1: Global Interpreter Lock
Section 70.2: Running in Multiple Threads
Section 70.3: Running in Multiple Processes
Section 70.4: Sharing State Between Threads
Section 70.5: Sharing State Between Processes
Chapter 71: Multithreading
Section 71.1: Basics of multithreading
Section 71.2: Communicating between threads
Section 71.3: Creating a worker pool
Section 71.4: Advanced use of multithreads
Section 71.5: Stoppable Thread with a while Loop
Chapter 72: Writing extensions
Section 72.1: Hello World with C Extension
Section 72.2: C Extension Using c++ and Boost
Section 72.3: Passing an open file to C Extensions
Chapter 73: Unit Testing
Section 73.1: Test Setup and Teardown within a unittest.TestCase
Section 73.2: Asserting on Exceptions
Section 73.3: Testing Exceptions
Section 73.4: Choosing Assertions Within Unittests
Section 73.5: Unit tests with pytest
Section 73.6: Mocking functions with unittest.mock.create_autospec
Chapter 74: Regular Expressions (Regex)
Section 74.1: Matching the beginning of a string
Section 74.2: Searching
Section 74.3: Precompiled patterns
Section 74.4: Flags
Section 74.5: Replacing
Section 74.6: Find All Non-Overlapping Matches
Section 74.7: Checking for allowed characters
Section 74.8: Splitting a string using regular expressions
Section 74.9: Grouping
Section 74.10: Escaping Special Characters
Section 74.11: Match an expression only in specific locations
Section 74.12: Iterating over matches using `re.finditer`
Chapter 75: Incompatibilities moving from Python 2 to Python 3
Section 75.1: Integer Division
Section 75.2: Unpacking Iterables
Section 75.3: Strings: Bytes versus Unicode
Section 75.4: Print statement vs. Print function
Section 75.5: Dierences between range and xrange functions
Section 75.6: Raising and handling Exceptions
Section 75.7: Leaked variables in list comprehension
Section 75.8: True, False and None
Section 75.9: User Input
Section 75.10: Comparison of dierent types
Section 75.11: .next() method on iterators renamed
Section 75.12: filter(), map() and zip() return iterators instead of sequences
Section 75.13: Renamed modules
Section 75.14: Removed operators <> and ``, synonymous with != and repr()
Section 75.15: long vs. int
Section 75.16: All classes are "new-style classes" in Python 3
Section 75.17: Reduce is no longer a built-in
Section 75.18: Absolute/Relative Imports
Section 75.19: map()
Section 75.20: The round() function tie-breaking and return type
Section 75.21: File I/O
Section 75.22: cmp function removed in Python 3
Section 75.23: Octal Constants
Section 75.24: Return value when writing to a file object
Section 75.25: exec statement is a function in Python 3
Section 75.26: encode/decode to hex no longer available
Section 75.27: Dictionary method changes
Section 75.28: Class Boolean Value
Section 75.29: hasattr function bug in Python 2
Chapter 76: Virtual environments
Section 76.1: Creating and using a virtual environment
Section 76.2: Specifying specific python version to use in script on Unix/Linux
Section 76.3: Creating a virtual environment for a dierent version of python
Section 76.4: Making virtual environments using Anaconda
Section 76.5: Managing multiple virtual enviroments with virtualenvwrapper
Section 76.6: Installing packages in a virtual environment
Section 76.7: Discovering which virtual environment you are using
Section 76.8: Checking if running inside a virtual environment
Section 76.9: Using virtualenv with fish shell
Chapter 77: Copying data
Section 77.1: Copy a dictionary
Section 77.2: Performing a shallow copy
Section 77.3: Performing a deep copy
Section 77.4: Performing a shallow copy of a list
Section 77.5: Copy a set
Chapter 78: Context Managers (“with” Statement)
Section 78.1: Introduction to context managers and the with statement
Section 78.2: Writing your own context manager
Section 78.3: Writing your own contextmanager using generator syntax
Section 78.4: Multiple context managers
Section 78.5: Assigning to a target
Section 78.6: Manage Resources
Chapter 79: Hidden Features
Section 79.1: Operator Overloading
Chapter 80: Unicode and bytes
Section 80.1: Encoding/decoding error handling
Section 80.2: File I/O
Section 80.3: Basics
Chapter 81: The __name__ special variable
Section 81.1: __name__ == '__main__'
Section 81.2: Use in logging
Section 81.3: function_class_or_module.__name__
Chapter 82: Checking Path Existence and Permissions
Section 82.1: Perform checks using os.access
Chapter 83: Python Networking
Section 83.1: Creating a Simple Http Server
Section 83.2: Creating a TCP server
Section 83.3: Creating a UDP Server
Section 83.4: Start Simple HttpServer in a thread and open the browser
Section 83.5: The simplest Python socket client-server example
Chapter 84: The Print Function
Section 84.1: Print basics
Section 84.2: Print parameters
Chapter 85: os.path
Section 85.1: Join Paths
Section 85.2: Path Component Manipulation
Section 85.3: Get the parent directory
Section 85.4: If the given path exists
Section 85.5: check if the given path is a directory, file, symbolic link, mount point etc
Section 85.6: Absolute Path from Relative Path
Chapter 86: Creating Python packages
Section 86.1: Introduction
Section 86.2: Uploading to PyPI
Section 86.3: Making package executable
Chapter 87: Parsing Command Line arguments
Section 87.1: Hello world in argparse
Section 87.2: Using command line arguments with argv
Section 87.3: Setting mutually exclusive arguments with argparse
Section 87.4: Basic example with docopt
Section 87.5: Custom parser error message with argparse
Section 87.6: Conceptual grouping of arguments with argparse.add_argument_group()
Section 87.7: Advanced example with docopt and docopt_dispatch
Chapter 88: HTML Parsing
Section 88.1: Using CSS selectors in BeautifulSoup
Section 88.2: PyQuery
Section 88.3: Locate a text after an element in BeautifulSoup
Chapter 89: Subprocess Library
Section 89.1: More flexibility with Popen
Section 89.2: Calling External Commands
Section 89.3: How to create the command list argument
Chapter 90: setup.py
Section 90.1: Purpose of setup.py
Section 90.2: Using source control metadata in setup.py
Section 90.3: Adding command line scripts to your python package
Section 90.4: Adding installation options
Chapter 91: Sockets
Section 91.1: Raw Sockets on Linux
Section 91.2: Sending data via UDP
Section 91.3: Receiving data via UDP
Section 91.4: Sending data via TCP
Section 91.5: Multi-threaded TCP Socket Server
Chapter 92: Recursion
Section 92.1: The What, How, and When of Recursion
Section 92.2: Tree exploration with recursion
Section 92.3: Sum of numbers from 1 to n
Section 92.4: Increasing the Maximum Recursion Depth
Section 92.5: Tail Recursion - Bad Practice
Section 92.6: Tail Recursion Optimization Through Stack Introspection
Chapter 93: Type Hints
Section 93.1: Adding types to a function
Section 93.2: NamedTuple
Section 93.3: Generic Types
Section 93.4: Variables and Attributes
Section 93.5: Class Members and Methods
Section 93.6: Type hints for keyword arguments
Chapter 94: pip: PyPI Package Manager
Section 94.1: Install Packages
Section 94.2: To list all packages installed using `pip`
Section 94.3: Upgrade Packages
Section 94.4: Uninstall Packages
Section 94.5: Updating all outdated packages on Linux
Section 94.6: Updating all outdated packages on Windows
Section 94.7: Create a requirements.txt file of all packages on the system
Section 94.8: Using a certain Python version with pip
Section 94.9: Create a requirements.txt file of packages only in the current virtualenv
Section 94.10: Installing packages not yet on pip as wheels
Chapter 95: Exceptions
Section 95.1: Catching Exceptions
Section 95.2: Do not catch everything!
Section 95.3: Re-raising exceptions
Section 95.4: Catching multiple exceptions
Section 95.5: Exception Hierarchy
Section 95.6: Else
Section 95.7: Raising Exceptions
Section 95.8: Creating custom exception types
Section 95.9: Practical examples of exception handling
Section 95.10: Exceptions are Objects too
Section 95.11: Running clean-up code with finally
Section 95.12: Chain exceptions with raise from
Chapter 96: Web scraping with Python
Section 96.1: Scraping using the Scrapy framework
Section 96.2: Scraping using Selenium WebDriver
Section 96.3: Basic example of using requests and lxml to scrape some data
Section 96.4: Maintaining web-scraping session with requests
Section 96.5: Scraping using BeautifulSoup4
Section 96.6: Simple web content download with urllib.request
Section 96.7: Modify Scrapy user agent
Section 96.8: Scraping with curl
Chapter 97: Distribution
Section 97.1: py2app
Section 97.2: cx_Freeze
Chapter 98: Property Objects
Section 98.1: Using the @property decorator for read-write properties
Section 98.2: Using the @property decorator
Section 98.3: Overriding just a getter, setter or a deleter of a property object
Section 98.4: Using properties without decorators
Chapter 99: Overloading
Section 99.1: Operator overloading
Section 99.2: Magic/Dunder Methods
Section 99.3: Container and sequence types
Section 99.4: Callable types
Section 99.5: Handling unimplemented behaviour
Chapter 100: Debugging
Section 100.1: Via IPython and ipdb
Section 100.2: The Python Debugger: Step-through Debugging with _pdb_
Section 100.3: Remote debugger
Chapter 101: Reading and Writing CSV
Section 101.1: Using pandas
Section 101.2: Writing a TSV file
Chapter 102: Dynamic code execution with `exec` and `eval`
Section 102.1: Executing code provided by untrusted user using exec, eval, or ast.literal_eval
Section 102.2: Evaluating a string containing a Python literal with ast.literal_eval
Section 102.3: Evaluating statements with exec
Section 102.4: Evaluating an expression with eval
Section 102.5: Precompiling an expression to evaluate it multiple times
Section 102.6: Evaluating an expression with eval using custom globals
Chapter 103: PyInstaller - Distributing Python Code
Section 103.1: Installation and Setup
Section 103.2: Using Pyinstaller
Section 103.3: Bundling to One Folder
Section 103.4: Bundling to a Single File
Chapter 104: Iterables and Iterators
Section 104.1: Iterator vs Iterable vs Generator
Section 104.2: Extract values one by one
Section 104.3: Iterating over entire iterable
Section 104.4: Verify only one element in iterable
Section 104.5: What can be iterable
Section 104.6: Iterator isn't reentrant!
Chapter 105: Data Visualization with Python
Section 105.1: Seaborn
Section 105.2: Matplotlib
Section 105.3: Plotly
Section 105.4: MayaVI
Chapter 106: The Interpreter (Command Line Console)
Section 106.1: Getting general help
Section 106.2: Referring to the last expression
Section 106.3: Opening the Python console
Section 106.4: The PYTHONSTARTUP variable
Section 106.5: Command line arguments
Section 106.6: Getting help about an object
Chapter 107: *args and **kwargs
Section 107.1: Using **kwargs when writing functions
Section 107.2: Using *args when writing functions
Section 107.3: Populating kwarg values with a dictionary
Section 107.4: Keyword-only and Keyword-required arguments
Section 107.5: Using **kwargs when calling functions
Section 107.6: **kwargs and default values
Section 107.7: Using *args when calling functions
Chapter 108: Garbage Collection
Section 108.1: Reuse of primitive objects
Section 108.2: Eects of the del command
Section 108.3: Reference Counting
Section 108.4: Garbage Collector for Reference Cycles
Section 108.5: Forcefully deallocating objects
Section 108.6: Viewing the refcount of an object
Section 108.7: Do not wait for the garbage collection to clean up
Section 108.8: Managing garbage collection
Chapter 109: Pickle data serialisation
Section 109.1: Using Pickle to serialize and deserialize an object
Section 109.2: Customize Pickled Data
Chapter 110: urllib
Section 110.1: HTTP GET
Section 110.2: HTTP POST
Section 110.3: Decode received bytes according to content type encoding
Chapter 111: Binary Data
Section 111.1: Format a list of values into a byte object
Section 111.2: Unpack a byte object according to a format string
Section 111.3: Packing a structure
Chapter 112: Python and Excel
Section 112.1: Read the excel data using xlrd module
Section 112.2: Format Excel files with xlsxwriter
Section 112.3: Put list data into a Excel's file
Section 112.4: OpenPyXL
Section 112.5: Create excel charts with xlsxwriter
Chapter 113: Idioms
Section 113.1: Dictionary key initializations
Section 113.2: Switching variables
Section 113.3: Use truth value testing
Section 113.4: Test for "__main__" to avoid unexpected code execution
Chapter 114: Method Overriding
Section 114.1: Basic method overriding
Chapter 115: Data Serialization
Section 115.1: Serialization using JSON
Section 115.2: Serialization using Pickle
Chapter 116: Python concurrency
Section 116.1: The multiprocessing module
Section 116.2: The threading module
Section 116.3: Passing data between multiprocessing processes
Chapter 117: Introduction to RabbitMQ using AMQPStorm
Section 117.1: How to consume messages from RabbitMQ
Section 117.2: How to publish messages to RabbitMQ
Section 117.3: How to create a delayed queue in RabbitMQ
Chapter 118: Descriptor
Section 118.1: Simple descriptor
Section 118.2: Two-way conversions
Chapter 119: Multiprocessing
Section 119.1: Running Two Simple Processes
Section 119.2: Using Pool and Map
Chapter 120: tempfile NamedTemporaryFile
Section 120.1: Create (and write to a) known, persistant temporary file
Chapter 121: Input, Subset and Output External Data Files using Pandas
Section 121.1: Basic Code to Import, Subset and Write External Data Files Using Pandas
Chapter 122: Writing to CSV from String or List
Section 122.1: Basic Write Example
Section 122.2: Appending a String as a newline in a CSV file
Chapter 123: Unzipping Files
Section 123.1: Using Python ZipFile.extractall() to decompress a ZIP file
Section 123.2: Using Python TarFile.extractall() to decompress a tarball
Chapter 124: Working with ZIP archives
Section 124.1: Examining Zipfile Contents
Section 124.2: Opening Zip Files
Section 124.3: Extracting zip file contents to a directory
Section 124.4: Creating new archives
Chapter 125: Stack
Section 125.1: Creating a Stack class with a List Object
Section 125.2: Parsing Parentheses
Chapter 126: Profiling
Section 126.1: %%timeit and %timeit in IPython
Section 126.2: Using cProfile (Preferred Profiler)
Section 126.3: timeit() function
Section 126.4: timeit command line
Section 126.5: line_profiler in command line
Chapter 127: User-Defined Methods
Section 127.1: Creating user-defined method objects
Section 127.2: Turtle example
Chapter 128: Working around the Global Interpreter Lock (GIL)
Section 128.1: Multiprocessing.Pool
Section 128.2: Cython nogil:
Chapter 129: Deployment
Section 129.1: Uploading a Conda Package
Chapter 130: Logging
Section 130.1: Introduction to Python Logging
Section 130.2: Logging exceptions
Chapter 131: Database Access
Section 131.1: SQLite
Section 131.2: Accessing MySQL database using MySQLdb
Section 131.3: Connection
Section 131.4: PostgreSQL Database access using psycopg2
Section 131.5: Oracle database
Section 131.6: Using sqlalchemy
Chapter 132: Python HTTP Server
Section 132.1: Running a simple HTTP server
Section 132.2: Serving files
Section 132.3: Basic handling of GET, POST, PUT using BaseHTTPRequestHandler
Section 132.4: Programmatic API of SimpleHTTPServer
Chapter 133: Web Server Gateway Interface (WSGI)
Section 133.1: Server Object (Method)
Chapter 134: Python Server Sent Events
Section 134.1: Flask SSE
Section 134.2: Asyncio SSE
Chapter 135: Connecting Python to SQL Server
Section 135.1: Connect to Server, Create Table, Query Data
Chapter 136: Sockets And Message Encryption/Decryption Between Client and Server
Section 136.1: Server side Implementation
Section 136.2: Client side Implementation
Chapter 137: Alternatives to switch statement from other languages
Section 137.1: Use what the language oers: the if/else construct
Section 137.2: Use a dict of functions
Section 137.3: Use class introspection
Section 137.4: Using a context manager
Chapter 138: List Comprehensions
Section 138.1: Conditional List Comprehensions
Section 138.2: List Comprehensions with Nested Loops
Section 138.3: Refactoring filter and map to list comprehensions
Section 138.4: Nested List Comprehensions
Section 138.5: Iterate two or more list simultaneously within list comprehension
Chapter 139: List destructuring (aka packing and unpacking)
Section 139.1: Destructuring assignment
Section 139.2: Packing function arguments
Section 139.3: Unpacking function arguments
Chapter 140: Accessing Python source code and bytecode
Section 140.1: Display the bytecode of a function
Section 140.2: Display the source code of an object
Section 140.3: Exploring the code object of a function
Chapter 141: Mixins
Section 141.1: Mixin
Section 141.2: Overriding Methods in Mixins
Chapter 142: Attribute Access
Section 142.1: Basic Attribute Access using the Dot Notation
Section 142.2: Setters, Getters & Properties
Chapter 143: ArcPy
Section 143.1: Printing one field's value for all rows of feature class in file geodatabase using Search Cursor
Section 143.2: createDissolvedGDB to create a file gdb on the workspace
Chapter 144: Abstract Base Classes (abc)
Section 144.1: Setting the ABCMeta metaclass
Section 144.2: Why/How to use ABCMeta and @abstractmethod
Chapter 145: Plugin and Extension Classes
Section 145.1: Mixins
Section 145.2: Plugins with Customized Classes
Chapter 146: Websockets
Section 146.1: Simple Echo with aiohttp
Section 146.2: Wrapper Class with aiohttp
Section 146.3: Using Autobahn as a Websocket Factory
Chapter 147: Immutable datatypes(int, float, str, tuple and frozensets)
Section 147.1: Individual characters of strings are not assignable
Section 147.2: Tuple's individual members aren't assignable
Section 147.3: Frozenset's are immutable and not assignable
Chapter 148: String representations of class instances: __str__ and __repr__ methods
Section 148.1: Motivation
Section 148.2: Both methods implemented, eval-round-trip style __repr__()
Chapter 149: Polymorphism
Section 149.1: Duck Typing
Section 149.2: Basic Polymorphism
Chapter 150: Non-ocial Python implementations
Section 150.1: IronPython
Section 150.2: Jython
Section 150.3: Transcrypt
Chapter 151: 2to3 tool
Section 151.1: Basic Usage
Chapter 152: Abstract syntax tree
Section 152.1: Analyze functions in a python script
Chapter 153: Unicode
Section 153.1: Encoding and decoding
Chapter 154: Python Serial Communication (pyserial)
Section 154.1: Initialize serial device
Section 154.2: Read from serial port
Section 154.3: Check what serial ports are available on your machine
Chapter 155: Neo4j and Cypher using Py2Neo
Section 155.1: Adding Nodes to Neo4j Graph
Section 155.2: Importing and Authenticating
Section 155.3: Adding Relationships to Neo4j Graph
Section 155.4: Query 1 : Autocomplete on News Titles
Section 155.5: Query 2 : Get News Articles by Location on a particular date
Section 155.6: Cypher Query Samples
Chapter 156: Basic Curses with Python
Section 156.1: The wrapper() helper function
Section 156.2: Basic Invocation Example
Chapter 157: Performance optimization
Section 157.1: Code profiling
Chapter 158: Templates in python
Section 158.1: Simple data output program using template
Section 158.2: Changing delimiter
Chapter 159: Pillow
Section 159.1: Read Image File
Section 159.2: Convert files to JPEG
Chapter 160: The pass statement
Section 160.1: Ignore an exception
Section 160.2: Create a new Exception that can be caught
Chapter 161: py.test
Section 161.1: Setting up py.test
Section 161.2: Intro to Test Fixtures
Section 161.3: Failing Tests
Chapter 162: Heapq
Section 162.1: Largest and smallest items in a collection
Section 162.2: Smallest item in a collection
Chapter 163: tkinter
Section 163.1: Geometry Managers
Section 163.2: A minimal tkinter Application
Chapter 164: CLI subcommands with precise help output
Section 164.1: Native way (no libraries)
Section 164.2: argparse (default help formatter)
Section 164.3: argparse (custom help formatter)
Chapter 165: PostgreSQL
Section 165.1: Getting Started
Chapter 166: Python Persistence
Section 166.1: Python Persistence
Section 166.2: Function utility for save and load
Chapter 167: Turtle Graphics
Section 167.1: Ninja Twist (Turtle Graphics)
Chapter 168: Design Patterns
Section 168.1: Introduction to design patterns and Singleton Pattern
Section 168.2: Strategy Pattern
Section 168.3: Proxy
Chapter 169: Multidimensional arrays
Section 169.1: Lists in lists
Section 169.2: Lists in lists in lists in..
Chapter 170: Audio
Section 170.1: Working with WAV files
Section 170.2: Convert any soundfile with python and mpeg
Section 170.3: Playing Windows' beeps
Section 170.4: Audio With Pyglet
Chapter 171: Pyglet
Section 171.1: Installation of Pyglet
Section 171.2: Hello World in Pyglet
Section 171.3: Playing Sound in Pyglet
Section 171.4: Using Pyglet for OpenGL
Section 171.5: Drawing Points Using Pyglet and OpenGL
Chapter 172: Flask
Section 172.1: Files and Templates
Section 172.2: The basics
Section 172.3: Routing URLs
Section 172.4: HTTP Methods
Section 172.5: Jinja Templating
Section 172.6: The Request Object
Chapter 173: groupby()
Section 173.1: Example 4
Section 173.2: Example 2
Section 173.3: Example 3
Chapter 174: pygame
Section 174.1: Pygame's mixer module
Section 174.2: Installing pygame
Chapter 175: hashlib
Section 175.1: MD5 hash of a string
Section 175.2: algorithm provided by OpenSSL
Chapter 176: getting start with GZip
Section 176.1: Read and write GNU zip files
Chapter 177: ctypes
Section 177.1: ctypes arrays
Section 177.2: Wrapping functions for ctypes
Section 177.3: Basic usage
Section 177.4: Common pitfalls
Section 177.5: Basic ctypes object
Section 177.6: Complex usage
Chapter 178: Creating a Windows service using Python
Section 178.1: A Python script that can be run as a service
Section 178.2: Running a Flask web application as a service
Chapter 179: Mutable vs Immutable (and Hashable) in Python
Section 179.1: Mutable vs Immutable
Section 179.2: Mutable and Immutable as Arguments
Chapter 180: Python speed of program
Section 180.1: Deque operations
Section 180.2: Algorithmic Notations..
Section 180.3: Notation
Section 180.4: List operations
Section 180.5: Set operations
Chapter 181: configparser
Section 181.1: Creating configuration file programatically
Section 181.2: Basic usage
Chapter 182: Commonwealth Exceptions
Section 182.1: Other Errors
Section 182.2: NameError: name '???' is not defined
Section 182.3: TypeErrors
Section 182.4: Syntax Error on good code
Section 182.5: IndentationErrors (or indentation SyntaxErrors)
Chapter 183: Optical Character Recognition
Section 183.1: PyTesseract
Section 183.2: PyOCR
Chapter 184: graph-tool
Section 184.1: PyDotPlus
Section 184.2: PyGraphviz
Chapter 185: Python Virtual Environment - virtualenv
Section 185.1: Installation
Section 185.2: Usage
Section 185.3: Install a package in your Virtualenv
Section 185.4: Other useful virtualenv commands
Chapter 186: sys
Section 186.1: Command line arguments
Section 186.2: Script name
Section 186.3: Standard error stream
Section 186.4: Ending the process prematurely and returning an exit code
Chapter 187: virtual environment with virtualenvwrapper
Section 187.1: Create virtual environment with virtualenvwrapper
Chapter 188: Create virtual environment with virtualenvwrapper in windows
Section 188.1: Virtual environment with virtualenvwrapper for windows
Chapter 189: Python Requests Post
Section 189.1: Simple Post
Section 189.2: Form Encoded Data
Section 189.3: File Upload
Section 189.4: Responses
Section 189.5: Authentication
Section 189.6: Proxies
Chapter 190: Python Lex-Yacc
Section 190.1: Getting Started with PLY
Section 190.2: The "Hello, World!" of PLY - A Simple Calculator
Section 190.3: Part 1: Tokenizing Input with Lex
Section 190.4: Part 2: Parsing Tokenized Input with Yacc
Chapter 191: ChemPy - python package
Section 191.1: Parsing formulae
Section 191.2: Balancing stoichiometry of a chemical reaction
Section 191.3: Balancing reactions
Section 191.4: Chemical equilibria
Section 191.5: Ionic strength
Section 191.6: Chemical kinetics (system of ordinary dierential equations)
Chapter 192: pyaudio
Section 192.1: Callback Mode Audio I/O
Section 192.2: Blocking Mode Audio I/O
Chapter 193: shelve
Section 193.1: Creating a new Shelf
Section 193.2: Sample code for shelve
Section 193.3: To summarize the interface (key is a string, data is an arbitrary object):
Section 193.4: Write-back
Chapter 194: IoT Programming with Python and Raspberry PI
Section 194.1: Example - Temperature sensor
Chapter 195: kivy - Cross-platform Python Framework for NUI Development
Section 195.1: First App
Chapter 196: Call Python from C#
Section 196.1: Python script to be called by C# application
Section 196.2: C# code calling Python script
Chapter 197: Similarities in syntax, Dierences in meaning: Python vs. JavaScript
Section 197.1: `in` with lists
Chapter 198: Raise Custom Errors / Exceptions
Section 198.1: Custom Exception
Section 198.2: Catch custom Exception
Chapter 199: Pandas Transform: Preform operations on groups and concatenate the results
Section 199.1: Simple transform
Section 199.2: Multiple results per group
Chapter 200: Security and Cryptography
Section 200.1: Secure Password Hashing
Section 200.2: Calculating a Message Digest
Section 200.3: Available Hashing Algorithms
Section 200.4: File Hashing
Section 200.5: Generating RSA signatures using pycrypto
Section 200.6: Asymmetric RSA encryption using pycrypto
Section 200.7: Symmetric encryption using pycrypto
Chapter 201: Secure Shell Connection in Python
Section 201.1: ssh connection
Chapter 202: Python Anti-Patterns
Section 202.1: Overzealous except clause
Section 202.2: Looking before you leap with processor-intensive function
Chapter 203: Common Pitfalls
Section 203.1: List multiplication and common references
Section 203.2: Mutable default argument
Section 203.3: Changing the sequence you are iterating over
Section 203.4: Integer and String identity
Section 203.5: Dictionaries are unordered
Section 203.6: Variable leaking in list comprehensions and for loops
Section 203.7: Chaining of or operator
Section 203.8: sys.argv[0] is the name of the file being executed
Section 203.9: Accessing int literals' attributes
Section 203.10: Global Interpreter Lock (GIL) and blocking threads
Section 203.11: Multiple return
Section 203.12: Pythonic JSON keys
Credits
You may also like
The book hasn't received reviews yet.