Python® Notes for Professionals book
معرفی کتاب «Python® Notes for Professionals book» نوشتهٔ GoalKicker Books، منتشرشده توسط نشر GoalKicker Books در سال 2018. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Python® Notes for Professionals book» در دستهٔ بدون دستهبندی قرار دارد.
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: Simple Mathematical Operators Section 9.1: Division Section 9.2: Addition Section 9.3: Exponentiation Section 9.4: Trigonometric Functions Section 9.5: Inplace Operations Section 9.6: Subtraction Section 9.7: Multiplication Section 9.8: Logarithms Section 9.9: Modulus Chapter 10: Bitwise Operators Section 10.1: Bitwise NOT Section 10.2: Bitwise XOR (Exclusive OR) Section 10.3: Bitwise AND Section 10.4: Bitwise OR Section 10.5: Bitwise Left Shift Section 10.6: Bitwise Right Shift Section 10.7: Inplace Operations Chapter 11: Boolean Operators Section 11.1: `and` and `or` are not guaranteed to return a boolean Section 11.2: A simple example Section 11.3: Short-circuit evaluation Section 11.4: and Section 11.5: or Section 11.6: not Chapter 12: Operator Precedence Section 12.1: Simple Operator Precedence Examples in python Chapter 13: Variable Scope and Binding Section 13.1: Nonlocal Variables Section 13.2: Global Variables Section 13.3: Local Variables Section 13.4: The del command Section 13.5: Functions skip class scope when looking up names Section 13.6: Local vs Global Scope Section 13.7: Binding Occurrence Chapter 14: Conditionals Section 14.1: Conditional Expression (or "The Ternary Operator") Section 14.2: if, elif, and else Section 14.3: Truth Values Section 14.4: Boolean Logic Expressions Section 14.5: Using the cmp function to get the comparison result of two objects Section 14.6: Else statement Section 14.7: Testing if an object is None and assigning it Section 14.8: If statement Chapter 15: Comparisons Section 15.1: Chain Comparisons Section 15.2: Comparison by `is` vs `==` Section 15.3: Greater than or less than Section 15.4: Not equal to Section 15.5: Equal To Section 15.6: Comparing Objects Chapter 16: Loops Section 16.1: Break and Continue in Loops Section 16.2: For loops Section 16.3: Iterating over lists Section 16.4: Loops with an "else" clause Section 16.5: The Pass Statement Section 16.6: Iterating over dictionaries Section 16.7: The "half loop" do-while Section 16.8: Looping and Unpacking Section 16.9: Iterating dierent portion of a list with dierent step size Section 16.10: While Loop Chapter 17: Arrays Section 17.1: Access individual elements through indexes Section 17.2: Basic Introduction to Arrays Section 17.3: Append any value to the array using append() method Section 17.4: Insert value in an array using insert() method Section 17.5: Extend python array using extend() method Section 17.6: Add items from list into array using fromlist() method Section 17.7: Remove any array element using remove() method Section 17.8: Remove last array element using pop() method Section 17.9: Fetch any element through its index using index() method Section 17.10: Reverse a python array using reverse() method Section 17.11: Get array buer information through buer_info() method Section 17.12: Check for number of occurrences of an element using count() method Section 17.13: Convert array to string using tostring() method Section 17.14: Convert array to a python list with same elements using tolist() method Section 17.15: Append a string to char array using fromstring() method Chapter 18: Multidimensional arrays Section 18.1: Lists in lists Section 18.2: Lists in lists in lists in.. Chapter 19: Dictionary Section 19.1: Introduction to Dictionary Section 19.2: Avoiding KeyError Exceptions Section 19.3: Iterating Over a Dictionary Section 19.4: Dictionary with default values Section 19.5: Merging dictionaries Section 19.6: Accessing keys and values Section 19.7: Accessing values of a dictionary Section 19.8: Creating a dictionary Section 19.9: Creating an ordered dictionary Section 19.10: Unpacking dictionaries using the ** operator Section 19.11: The trailing comma Section 19.12: The dict() constructor Section 19.13: Dictionaries Example Section 19.14: All combinations of dictionary values Chapter 20: List Section 20.1: List methods and supported operators Section 20.2: Accessing list values Section 20.3: Checking if list is empty Section 20.4: Iterating over a list Section 20.5: Checking whether an item is in a list Section 20.6: Any and All Section 20.7: Reversing list elements Section 20.8: Concatenate and Merge lists Section 20.9: Length of a list Section 20.10: Remove duplicate values in list Section 20.11: Comparison of lists Section 20.12: Accessing values in nested list Section 20.13: Initializing a List to a Fixed Number of Elements Chapter 21: List comprehensions Section 21.1: List Comprehensions Section 21.2: Conditional List Comprehensions Section 21.3: Avoid repetitive and expensive operations using conditional clause Section 21.4: Dictionary Comprehensions Section 21.5: List Comprehensions with Nested Loops Section 21.6: Generator Expressions Section 21.7: Set Comprehensions Section 21.8: Refactoring filter and map to list comprehensions Section 21.9: Comprehensions involving tuples Section 21.10: Counting Occurrences Using Comprehension Section 21.11: Changing Types in a List Section 21.12: Nested List Comprehensions Section 21.13: Iterate two or more list simultaneously within list comprehension Chapter 22: List slicing (selecting parts of lists) Section 22.1: Using the third "step" argument Section 22.2: Selecting a sublist from a list Section 22.3: Reversing a list with slicing Section 22.4: Shifting a list using slicing Chapter 23: groupby() Section 23.1: Example 4 Section 23.2: Example 2 Section 23.3: Example 3 Chapter 24: Linked lists Section 24.1: Single linked list example Chapter 25: Linked List Node Section 25.1: Write a simple Linked List Node in python Chapter 26: Filter Section 26.1: Basic use of filter Section 26.2: Filter without function Section 26.3: Filter as short-circuit check Section 26.4: Complementary function: filterfalse, ifilterfalse Chapter 27: Heapq Section 27.1: Largest and smallest items in a collection Section 27.2: Smallest item in a collection Chapter 28: Tuple Section 28.1: Tuple Section 28.2: Tuples are immutable Section 28.3: Packing and Unpacking Tuples Section 28.4: Built-in Tuple Functions Section 28.5: Tuple Are Element-wise Hashable and Equatable Section 28.6: Indexing Tuples Section 28.7: Reversing Elements Chapter 29: Basic Input and Output Section 29.1: Using the print function Section 29.2: Input from a File Section 29.3: Read from stdin Section 29.4: Using input() and raw_input() Section 29.5: Function to prompt user for a number Section 29.6: Printing a string without a newline at the end Chapter 30: Files & Folders I/O Section 30.1: File modes Section 30.2: Reading a file line-by-line Section 30.3: Iterate files (recursively) Section 30.4: Getting the full contents of a file Section 30.5: Writing to a file Section 30.6: Check whether a file or path exists Section 30.7: Random File Access Using mmap Section 30.8: Replacing text in a file Section 30.9: Checking if a file is empty Section 30.10: Read a file between a range of lines Section 30.11: Copy a directory tree Section 30.12: Copying contents of one file to a dierent file Chapter 31: os.path Section 31.1: Join Paths Section 31.2: Path Component Manipulation Section 31.3: Get the parent directory Section 31.4: If the given path exists Section 31.5: check if the given path is a directory, file, symbolic link, mount point etc Section 31.6: Absolute Path from Relative Path Chapter 32: Iterables and Iterators Section 32.1: Iterator vs Iterable vs Generator Section 32.2: Extract values one by one Section 32.3: Iterating over entire iterable Section 32.4: Verify only one element in iterable Section 32.5: What can be iterable Section 32.6: Iterator isn't reentrant! Chapter 33: Functions Section 33.1: Defining and calling simple functions Section 33.2: Defining a function with an arbitrary number of arguments Section 33.3: Lambda (Inline/Anonymous) Functions Section 33.4: Defining a function with optional arguments Section 33.5: Defining a function with optional mutable arguments Section 33.6: Argument passing and mutability Section 33.7: Returning values from functions Section 33.8: Closure Section 33.9: Forcing the use of named parameters Section 33.10: Nested functions Section 33.11: Recursion limit Section 33.12: Recursive Lambda using assigned variable Section 33.13: Recursive functions Section 33.14: Defining a function with arguments Section 33.15: Iterable and dictionary unpacking Section 33.16: Defining a function with multiple arguments Chapter 34: Defining functions with list arguments Section 34.1: Function and Call Chapter 35: Functional Programming in Python Section 35.1: Lambda Function Section 35.2: Map Function Section 35.3: Reduce Function Section 35.4: Filter Function Chapter 36: Partial functions Section 36.1: Raise the power Chapter 37: Decorators Section 37.1: Decorator function Section 37.2: Decorator class Section 37.3: Decorator with arguments (decorator factory) Section 37.4: Making a decorator look like the decorated function Section 37.5: Using a decorator to time a function Section 37.6: Create singleton class with a decorator Chapter 38: Classes Section 38.1: Introduction to classes Section 38.2: Bound, unbound, and static methods Section 38.3: Basic inheritance Section 38.4: Monkey Patching Section 38.5: New-style vs. old-style classes Section 38.6: Class methods: alternate initializers Section 38.7: Multiple Inheritance Section 38.8: Properties Section 38.9: Default values for instance variables Section 38.10: Class and instance variables Section 38.11: Class composition Section 38.12: Listing All Class Members Section 38.13: Singleton class Section 38.14: Descriptors and Dotted Lookups Chapter 39: Metaclasses Section 39.1: Basic Metaclasses Section 39.2: Singletons using metaclasses Section 39.3: Using a metaclass Section 39.4: Introduction to Metaclasses Section 39.5: Custom functionality with metaclasses Section 39.6: The default metaclass Chapter 40: String Formatting Section 40.1: Basics of String Formatting Section 40.2: Alignment and padding Section 40.3: Format literals (f-string) Section 40.4: Float formatting Section 40.5: Named placeholders Section 40.6: String formatting with datetime Section 40.7: Formatting Numerical Values Section 40.8: Nested formatting Section 40.9: Format using Getitem and Getattr Section 40.10: Padding and truncating strings, combined Section 40.11: Custom formatting for a class Chapter 41: String Methods Section 41.1: Changing the capitalization of a string Section 41.2: str.translate: Translating characters in a string Section 41.3: str.format and f-strings: Format values into a string Section 41.4: String module's useful constants Section 41.5: Stripping unwanted leading/trailing characters from a string Section 41.6: Reversing a string Section 41.7: Split a string based on a delimiter into a list of strings Section 41.8: Replace all occurrences of one substring with another substring Section 41.9: Testing what a string is composed of Section 41.10: String Contains Section 41.11: Join a list of strings into one string Section 41.12: Counting number of times a substring appears in a string Section 41.13: Case insensitive string comparisons Section 41.14: Justify strings Section 41.15: Test the starting and ending characters of a string Section 41.16: Conversion between str or bytes data and unicode characters Chapter 42: Using loops within functions Section 42.1: Return statement inside loop in a function Chapter 43: Importing modules Section 43.1: Importing a module Section 43.2: The __all__ special variable Section 43.3: Import modules from an arbitrary filesystem location Section 43.4: Importing all names from a module Section 43.5: Programmatic importing Section 43.6: PEP8 rules for Imports Section 43.7: Importing specific names from a module Section 43.8: Importing submodules Section 43.9: Re-importing a module Section 43.10: __import__() function Chapter 44: Dierence between Module and Package Section 44.1: Modules Section 44.2: Packages Chapter 45: Math Module Section 45.1: Rounding: round, floor, ceil, trunc Section 45.2: Trigonometry Section 45.3: Pow for faster exponentiation Section 45.4: Infinity and NaN ("not a number") Section 45.5: Logarithms Section 45.6: Constants Section 45.7: Imaginary Numbers Section 45.8: Copying signs Section 45.9: Complex numbers and the cmath module Chapter 46: Complex math Section 46.1: Advanced complex arithmetic Section 46.2: Basic complex arithmetic Chapter 47: Collections module Section 47.1: collections.Counter Section 47.2: collections.OrderedDict Section 47.3: collections.defaultdict Section 47.4: collections.namedtuple Section 47.5: collections.deque Section 47.6: collections.ChainMap Chapter 48: Operator module Section 48.1: Itemgetter Section 48.2: Operators as alternative to an infix operator Section 48.3: Methodcaller Chapter 49: JSON Module Section 49.1: Storing data in a file Section 49.2: Retrieving data from a file Section 49.3: Formatting JSON output Section 49.4: `load` vs `loads`, `dump` vs `dumps` Section 49.5: Calling `json.tool` from the command line to pretty-print JSON output Section 49.6: JSON encoding custom objects Section 49.7: Creating JSON from Python dict Section 49.8: Creating Python dict from JSON Chapter 50: Sqlite3 Module Section 50.1: Sqlite3 - Not require separate server process Section 50.2: Getting the values from the database and Error handling Chapter 51: The os Module Section 51.1: makedirs - recursive directory creation Section 51.2: Create a directory Section 51.3: Get current directory Section 51.4: Determine the name of the operating system Section 51.5: Remove a directory Section 51.6: Follow a symlink (POSIX) Section 51.7: Change permissions on a file Chapter 52: The locale Module Section 52.1: Currency Formatting US Dollars Using the locale Module Chapter 53: Itertools Module Section 53.1: Combinations method in Itertools Module Section 53.2: itertools.dropwhile Section 53.3: Zipping two iterators until they are both exhausted Section 53.4: Take a slice of a generator Section 53.5: Grouping items from an iterable object using a function Section 53.6: itertools.takewhile Section 53.7: itertools.permutations Section 53.8: itertools.repeat Section 53.9: Get an accumulated sum of numbers in an iterable Section 53.10: Cycle through elements in an iterator Section 53.11: itertools.product Section 53.12: itertools.count Section 53.13: Chaining multiple iterators together Chapter 54: Asyncio Module Section 54.1: Coroutine and Delegation Syntax Section 54.2: Asynchronous Executors Section 54.3: Using UVLoop Section 54.4: Synchronization Primitive: Event Section 54.5: A Simple Websocket Section 54.6: Common Misconception about asyncio Chapter 55: Random module Section 55.1: Creating a random user password Section 55.2: Create cryptographically secure random numbers Section 55.3: Random and sequences: shue, choice and sample Section 55.4: Creating random integers and floats: randint, randrange, random, and uniform Section 55.5: Reproducible random numbers: Seed and State Section 55.6: Random Binary Decision Chapter 56: Functools Module Section 56.1: partial Section 56.2: cmp_to_key Section 56.3: lru_cache Section 56.4: total_ordering Section 56.5: reduce Chapter 57: The dis module Section 57.1: What is Python bytecode? Section 57.2: Constants in the dis module Section 57.3: Disassembling modules Chapter 58: The base64 Module Section 58.1: Encoding and Decoding Base64 Section 58.2: Encoding and Decoding Base32 Section 58.3: Encoding and Decoding Base16 Section 58.4: Encoding and Decoding ASCII85 Section 58.5: Encoding and Decoding Base85 Chapter 59: Queue Module Section 59.1: Simple example Chapter 60: Deque Module Section 60.1: Basic deque using Section 60.2: Available methods in deque Section 60.3: limit deque size Section 60.4: Breadth First Search Chapter 61: Webbrowser Module Section 61.1: Opening a URL with Default Browser Section 61.2: Opening a URL with Dierent Browsers Chapter 62: tkinter Section 62.1: Geometry Managers Section 62.2: A minimal tkinter Application Chapter 63: pyautogui module Section 63.1: Mouse Functions Section 63.2: Keyboard Functions Section 63.3: Screenshot And Image Recognition Chapter 64: Indexing and Slicing Section 64.1: Basic Slicing Section 64.2: Reversing an object Section 64.3: Slice assignment Section 64.4: Making a shallow copy of an array Section 64.5: Indexing custom classes: __getitem__, __setitem__ and __delitem__ Section 64.6: Basic Indexing Chapter 65: Plotting with Matplotlib Section 65.1: Plots with Common X-axis but dierent Y-axis : Using twinx() Section 65.2: Plots with common Y-axis and dierent X-axis using twiny() Section 65.3: A Simple Plot in Matplotlib Section 65.4: Adding more features to a simple plot : axis labels, title, axis ticks, grid, and legend Section 65.5: Making multiple plots in the same figure by superimposition similar to MATLAB Section 65.6: Making multiple Plots in the same figure using plot superimposition with separate plot commands Chapter 66: graph-tool Section 66.1: PyDotPlus Section 66.2: PyGraphviz Chapter 67: Generators Section 67.1: Introduction Section 67.2: Infinite sequences Section 67.3: Sending objects to a generator Section 67.4: Yielding all values from another iterable Section 67.5: Iteration Section 67.6: The next() function Section 67.7: Coroutines Section 67.8: Refactoring list-building code Section 67.9: Yield with recursion: recursively listing all files in a directory Section 67.10: Generator expressions Section 67.11: Using a generator to find Fibonacci Numbers Section 67.12: Searching Section 67.13: Iterating over generators in parallel Chapter 68: Reduce Section 68.1: Overview Section 68.2: Using reduce Section 68.3: Cumulative product Section 68.4: Non short-circuit variant of any/all Chapter 69: Map Function Section 69.1: Basic use of map, itertools.imap and future_builtins.map Section 69.2: Mapping each value in an iterable Section 69.3: Mapping values of dierent iterables Section 69.4: Transposing with Map: Using "None" as function argument (python 2.x only) Section 69.5: Series and Parallel Mapping Chapter 70: Exponentiation Section 70.1: Exponentiation using builtins: ** and pow() Section 70.2: Square root: math.sqrt() and cmath.sqrt Section 70.3: Modular exponentiation: pow() with 3 arguments Section 70.4: Computing large integer roots Section 70.5: Exponentiation using the math module: math.pow() Section 70.6: Exponential function: math.exp() and cmath.exp() Section 70.7: Exponential function minus 1: math.expm1() Section 70.8: Magic methods and exponentiation: builtin, math and cmath Section 70.9: Roots: nth-root with fractional exponents Chapter 71: Searching Section 71.1: Searching for an element Section 71.2: Searching in custom classes: __contains__ and __iter__ Section 71.3: Getting the index for strings: str.index(), str.rindex() and str.find(), str.rfind() Section 71.4: Getting the index list and tuples: list.index(), tuple.index() Section 71.5: Searching key(s) for a value in dict Section 71.6: Getting the index for sorted sequences: bisect.bisect_left() Section 71.7: Searching nested sequences Chapter 72: Sorting, Minimum and Maximum Section 72.1: Make custom classes orderable Section 72.2: Special case: dictionaries Section 72.3: Using the key argument Section 72.4: Default Argument to max, min Section 72.5: Getting a sorted sequence Section 72.6: Extracting N largest or N smallest items from an iterable Section 72.7: Getting the minimum or maximum of several values Section 72.8: Minimum and Maximum of a sequence Chapter 73: Counting Section 73.1: Counting all occurrence of all items in an iterable: collections.Counter Section 73.2: Getting the most common value(-s): collections.Counter.most_common() Section 73.3: Counting the occurrences of one item in a sequence: list.count() and tuple.count() Section 73.4: Counting the occurrences of a substring in a string: str.count() Section 73.5: Counting occurrences in numpy array Chapter 74: The Print Function Section 74.1: Print basics Section 74.2: Print parameters Chapter 75: Regular Expressions (Regex) Section 75.1: Matching the beginning of a string Section 75.2: Searching Section 75.3: Precompiled patterns Section 75.4: Flags Section 75.5: Replacing Section 75.6: Find All Non-Overlapping Matches Section 75.7: Checking for allowed characters Section 75.8: Splitting a string using regular expressions Section 75.9: Grouping Section 75.10: Escaping Special Characters Section 75.11: Match an expression only in specific locations Section 75.12: Iterating over matches using `re.finditer` Chapter 76: Copying data Section 76.1: Copy a dictionary Section 76.2: Performing a shallow copy Section 76.3: Performing a deep copy Section 76.4: Performing a shallow copy of a list Section 76.5: Copy a set Chapter 77: Context Managers (“with” Statement) Section 77.1: Introduction to context managers and the with statement Section 77.2: Writing your own context manager Section 77.3: Writing your own contextmanager using generator syntax Section 77.4: Multiple context managers Section 77.5: Assigning to a target Section 77.6: Manage Resources Chapter 78: The __name__ special variable Section 78.1: __name__ == '__main__' Section 78.2: Use in logging Section 78.3: function_class_or_module.__name__ Chapter 79: Checking Path Existence and Permissions Section 79.1: Perform checks using os.access Chapter 80: Creating Python packages Section 80.1: Introduction Section 80.2: Uploading to PyPI Section 80.3: Making package executable Chapter 81: Usage of "pip" module: PyPI Package Manager Section 81.1: Example use of commands Section 81.2: Handling ImportError Exception Section 81.3: Force install Chapter 82: pip: PyPI Package Manager Section 82.1: Install Packages Section 82.2: To list all packages installed using `pip` Section 82.3: Upgrade Packages Section 82.4: Uninstall Packages Section 82.5: Updating all outdated packages on Linux Section 82.6: Updating all outdated packages on Windows Section 82.7: Create a requirements.txt file of all packages on the system Section 82.8: Using a certain Python version with pip Section 82.9: Create a requirements.txt file of packages only in the current virtualenv Section 82.10: Installing packages not yet on pip as wheels Chapter 83: Parsing Command Line arguments Section 83.1: Hello world in argparse Section 83.2: Using command line arguments with argv Section 83.3: Setting mutually exclusive arguments with argparse Section 83.4: Basic example with docopt Section 83.5: Custom parser error message with argparse Section 83.6: Conceptual grouping of arguments with argparse.add_argument_group() Section 83.7: Advanced example with docopt and docopt_dispatch Chapter 84: Subprocess Library Section 84.1: More flexibility with Popen Section 84.2: Calling External Commands Section 84.3: How to create the command list argument Chapter 85: setup.py Section 85.1: Purpose of setup.py Section 85.2: Using source control metadata in setup.py Section 85.3: Adding command line scripts to your python package Section 85.4: Adding installation options Chapter 86: Recursion Section 86.1: The What, How, and When of Recursion Section 86.2: Tree exploration with recursion Section 86.3: Sum of numbers from 1 to n Section 86.4: Increasing the Maximum Recursion Depth Section 86.5: Tail Recursion - Bad Practice Section 86.6: Tail Recursion Optimization Through Stack Introspection Chapter 87: Type Hints Section 87.1: Adding types to a function Section 87.2: NamedTuple Section 87.3: Generic Types Section 87.4: Variables and Attributes Section 87.5: Class Members and Methods Section 87.6: Type hints for keyword arguments Chapter 88: Exceptions Section 88.1: Catching Exceptions Section 88.2: Do not catch everything! Section 88.3: Re-raising exceptions Section 88.4: Catching multiple exceptions Section 88.5: Exception Hierarchy Section 88.6: Else Section 88.7: Raising Exceptions Section 88.8: Creating custom exception types Section 88.9: Practical examples of exception handling Section 88.10: Exceptions are Objects too Section 88.11: Running clean-up code with finally Section 88.12: Chain exceptions with raise from Chapter 89: Raise Custom Errors / Exceptions Section 89.1: Custom Exception Section 89.2: Catch custom Exception Chapter 90: Commonwealth Exceptions Section 90.1: Other Errors Section 90.2: NameError: name '???' is not defined Section 90.3: TypeErrors Section 90.4: Syntax Error on good code Section 90.5: IndentationErrors (or indentation SyntaxErrors) Chapter 91: urllib Section 91.1: HTTP GET Section 91.2: HTTP POST Section 91.3: Decode received bytes according to content type encoding Chapter 92: Web scraping with Python Section 92.1: Scraping using the Scrapy framework Section 92.2: Scraping using Selenium WebDriver Section 92.3: Basic example of using requests and lxml to scrape some data Section 92.4: Maintaining web-scraping session with requests Section 92.5: Scraping using BeautifulSoup4 Section 92.6: Simple web content download with urllib.request Section 92.7: Modify Scrapy user agent Section 92.8: Scraping with curl Chapter 93: HTML Parsing Section 93.1: Using CSS selectors in BeautifulSoup Section 93.2: PyQuery Section 93.3: Locate a text after an element in BeautifulSoup Chapter 94: Manipulating XML Section 94.1: Opening and reading using an ElementTree Section 94.2: Create and Build XML Documents Section 94.3: Modifying an XML File Section 94.4: Searching the XML with XPath Section 94.5: Opening and reading large XML files using iterparse (incremental parsing) Chapter 95: Python Requests Post Section 95.1: Simple Post Section 95.2: Form Encoded Data Section 95.3: File Upload Section 95.4: Responses Section 95.5: Authentication Section 95.6: Proxies Chapter 96: Distribution Section 96.1: py2app Section 96.2: cx_Freeze Chapter 97: Property Objects Section 97.1: Using the @property decorator for read-write properties Section 97.2: Using the @property decorator Section 97.3: Overriding just a getter, setter or a deleter of a property object Section 97.4: Using properties without decorators Chapter 98: Overloading Section 98.1: Operator overloading Section 98.2: Magic/Dunder Methods Section 98.3: Container and sequence types Section 98.4: Callable types Section 98.5: Handling unimplemented behaviour Chapter 99: Polymorphism Section 99.1: Duck Typing Section 99.2: Basic Polymorphism Chapter 100: Method Overriding Section 100.1: Basic method overriding Chapter 101: User-Defined Methods Section 101.1: Creating user-defined method objects Section 101.2: Turtle example Chapter 102: String representations of class instances: __str__ and __repr__ methods Section 102.1: Motivation Section 102.2: Both methods implemented, eval-round-trip style __repr__() Chapter 103: Debugging Section 103.1: Via IPython and ipdb Section 103.2: The Python Debugger: Step-through Debugging with _pdb_ Section 103.3: Remote debugger Chapter 104: Reading and Writing CSV Section 104.1: Using pandas Section 104.2: Writing a TSV file Chapter 105: Writing to CSV from String or List Section 105.1: Basic Write Example Section 105.2: Appending a String as a newline in a CSV file Chapter 106: Dynamic code execution with `exec` and `eval` Section 106.1: Executing code provided by untrusted user using exec, eval, or ast.literal_eval Section 106.2: Evaluating a string containing a Python literal with ast.literal_eval Section 106.3: Evaluating statements with exec Section 106.4: Evaluating an expression with eval Section 106.5: Precompiling an expression to evaluate it multiple times Section 106.6: Evaluating an expression with eval using custom globals Chapter 107: PyInstaller - Distributing Python Code Section 107.1: Installation and Setup Section 107.2: Using 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: Simple Mathematical Operators Section 9.1: Division Section 9.2: Addition Section 9.3: Exponentiation Section 9.4: Trigonometric Functions Section 9.5: Inplace Operations Section 9.6: Subtraction Section 9.7: Multiplication Section 9.8: Logarithms Section 9.9: Modulus Chapter 10: Bitwise Operators Section 10.1: Bitwise NOT Section 10.2: Bitwise XOR (Exclusive OR) Section 10.3: Bitwise AND Section 10.4: Bitwise OR Section 10.5: Bitwise Left Shift Section 10.6: Bitwise Right Shift Section 10.7: Inplace Operations Chapter 11: Boolean Operators Section 11.1: `and` and `or` are not guaranteed to return a boolean Section 11.2: A simple example Section 11.3: Short-circuit evaluation Section 11.4: and Section 11.5: or Section 11.6: not Chapter 12: Operator Precedence Section 12.1: Simple Operator Precedence Examples in python Chapter 13: Variable Scope and Binding Section 13.1: Nonlocal Variables Section 13.2: Global Variables Section 13.3: Local Variables Section 13.4: The del command Section 13.5: Functions skip class scope when looking up names Section 13.6: Local vs Global Scope Section 13.7: Binding Occurrence Chapter 14: Conditionals Section 14.1: Conditional Expression (or "The Ternary Operator") Section 14.2: if, elif, and else Section 14.3: Truth Values Section 14.4: Boolean Logic Expressions Section 14.5: Using the cmp function to get the comparison result of two objects Section 14.6: Else statement Section 14.7: Testing if an object is None and assigning it Section 14.8: If statement Chapter 15: Comparisons Section 15.1: Chain Comparisons Section 15.2: Comparison by `is` vs `==` Section 15.3: Greater than or less than Section 15.4: Not equal to Section 15.5: Equal To Section 15.6: Comparing Objects Chapter 16: Loops Section 16.1: Break and Continue in Loops Section 16.2: For loops Section 16.3: Iterating over lists Section 16.4: Loops with an "else" clause Section 16.5: The Pass Statement Section 16.6: Iterating over dictionaries Section 16.7: The "half loop" do-while Section 16.8: Looping and Unpacking Section 16.9: Iterating dierent portion of a list with dierent step size Section 16.10: While Loop Chapter 17: Arrays Section 17.1: Access individual elements through indexes Section 17.2: Basic Introduction to Arrays Section 17.3: Append any value to the array using append() method Section 17.4: Insert value in an array using insert() method Section 17.5: Extend python array using extend() method Section 17.6: Add items from list into array using fromlist() method Section 17.7: Remove any array element using remove() method Section 17.8: Remove last array element using pop() method Section 17.9: Fetch any element through its index using index() method Section 17.10: Reverse a python array using reverse() method Section 17.11: Get array buer information through buer_info() method Section 17.12: Check for number of occurrences of an element using count() method Section 17.13: Convert array to string using tostring() method Section 17.14: Convert array to a python list with same elements using tolist() method Section 17.15: Append a string to char array using fromstring() method Chapter 18: Multidimensional arrays Section 18.1: Lists in lists Section 18.2: Lists in lists in lists in.. Chapter 19: Dictionary Section 19.1: Introduction to Dictionary Section 19.2: Avoiding KeyError Exceptions Section 19.3: Iterating Over a Dictionary Section 19.4: Dictionary with default values Section 19.5: Merging dictionaries Section 19.6: Accessing keys and values Section 19.7: Accessing values of a dictionary Section 19.8: Creating a dictionary Section 19.9: Creating an ordered dictionary Section 19.10: Unpacking dictionaries using the ** operator Section 19.11: The trailing comma Section 19.12: The dict() constructor Section 19.13: Dictionaries Example Section 19.14: All combinations of dictionary values Chapter 20: List Section 20.1: List methods and supported operators Section 20.2: Accessing list values Section 20.3: Checking if list is empty Section 20.4: Iterating over a list Section 20.5: Checking whether an item is in a list Section 20.6: Any and All Section 20.7: Reversing list elements Section 20.8: Concatenate and Merge lists Section 20.9: Length of a list Section 20.10: Remove duplicate values in list Section 20.11: Comparison of lists Section 20.12: Accessing values in nested list Section 20.13: Initializing a List to a Fixed Number of Elements Chapter 21: List comprehensions Section 21.1: List Comprehensions Section 21.2: Conditional List Comprehensions Section 21.3: Avoid repetitive and expensive operations using conditional clause Section 21.4: Dictionary Comprehensions Section 21.5: List Comprehensions with Nested Loops Section 21.6: Generator Expressions Section 21.7: Set Comprehensions Section 21.8: Refactoring filter and map to list comprehensions Section 21.9: Comprehensions involving tuples Section 21.10: Counting Occurrences Using Comprehension Section 21.11: Changing Types in a List Section 21.12: Nested List Comprehensions Section 21.13: Iterate two or more list simultaneously within list comprehension Chapter 22: List slicing (selecting parts of lists) Section 22.1: Using the third "step" argument Section 22.2: Selecting a sublist from a list Section 22.3: Reversing a list with slicing Section 22.4: Shifting a list using slicing Chapter 23: groupby() Section 23.1: Example 4 Section 23.2: Example 2 Section 23.3: Example 3 Chapter 24: Linked lists Section 24.1: Single linked list example Chapter 25: Linked List Node Section 25.1: Write a simple Linked List Node in python Chapter 26: Filter Section 26.1: Basic use of filter Section 26.2: Filter without function Section 26.3: Filter as short-circuit check Section 26.4: Complementary function: filterfalse, ifilterfalse Chapter 27: Heapq Section 27.1: Largest and smallest items in a collection Section 27.2: Smallest item in a collection Chapter 28: Tuple Section 28.1: Tuple Section 28.2: Tuples are immutable Section 28.3: Packing and Unpacking Tuples Section 28.4: Built-in Tuple Functions Section 28.5: Tuple Are Element-wise Hashable and Equatable Section 28.6: Indexing Tuples Section 28.7: Reversing Elements Chapter 29: Basic Input and Output Section 29.1: Using the print function Section 29.2: Input from a File Section 29.3: Read from stdin Section 29.4: Using input() and raw_input() Section 29.5: Function to prompt user for a number Section 29.6: Printing a string without a newline at the end Chapter 30: Files & Folders I/O Section 30.1: File modes Section 30.2: Reading a file line-by-line Section 30.3: Iterate files (recursively) Section 30.4: Getting the full contents of a file Section 30.5: Writing to a file Section 30.6: Check whether a file or path exists Section 30.7: Random File Access Using mmap Section 30.8: Replacing text in a file Section 30.9: Checking if a file is empty Section 30.10: Read a file between a range of lines Section 30.11: Copy a directory tree Section 30.12: Copying contents of one file to a dierent file Chapter 31: os.path Section 31.1: Join Paths Section 31.2: Path Component Manipulation Section 31.3: Get the parent directory Section 31.4: If the given path exists Section 31.5: check if the given path is a directory, file, symbolic link, mount point etc Section 31.6: Absolute Path from Relative Path Chapter 32: Iterables and Iterators Section 32.1: Iterator vs Iterable vs Generator Section 32.2: Extract values one by one Section 32.3: Iterating over entire iterable Section 32.4: Verify only one element in iterable Section 32.5: What can be iterable Section 32.6: Iterator isn't reentrant! Chapter 33: Functions Section 33.1: Defining and calling simple functions Section 33.2: Defining a function with an arbitrary number of arguments Section 33.3: Lambda (Inline/Anonymous) Functions Section 33.4: Defining a function with optional arguments Section 33.5: Defining a function with optional mutable arguments Section 33.6: Argument passing and mutability Section 33.7: Returning values from functions Section 33.8: Closure Section 33.9: Forcing the use of named parameters Section 33.10: Nested functions Section 33.11: Recursion limit Section 33.12: Recursive Lambda using assigned variable Section 33.13: Recursive functions Section 33.14: Defining a function with arguments Section 33.15: Iterable and dictionary unpacking Section 33.16: Defining a function with multiple arguments Chapter 34: Defining functions with list arguments Section 34.1: Function and Call Chapter 35: Functional Programming in Python Section 35.1: Lambda Function Section 35.2: Map Function Section 35.3: Reduce Function Section 35.4: Filter Function Chapter 36: Partial functions Section 36.1: Raise the power Chapter 37: Decorators Section 37.1: Decorator function Section 37.2: Decorator class Section 37.3: Decorator with arguments (decorator factory) Section 37.4: Making a decorator look like the decorated function Section 37.5: Using a decorator to time a function Section 37.6: Create singleton class with a decorator Chapter 38: Classes Section 38.1: Introduction to classes Section 38.2: Bound, unbound, and static methods Section 38.3: Basic inheritance Section 38.4: Monkey Patching Section 38.5: New-style vs. old-style classes Section 38.6: Class methods: alternate initializers Section 38.7: Multiple Inheritance Section 38.8: Properties Section 38.9: Default values for instance variables Section 38.10: Class and instance variables Section 38.11: Class composition Section 38.12: Listing All Class Members Section 38.13: Singleton class Section 38.14: Descriptors and Dotted Lookups Chapter 39: Metaclasses Section 39.1: Basic Metaclasses Section 39.2: Singletons using metaclasses Section 39.3: Using a metaclass Section 39.4: Introduction to Metaclasses Section 39.5: Custom functionality with metaclasses Section 39.6: The default metaclass Chapter 40: String Formatting Section 40.1: Basics of String Formatting Section 40.2: Alignment and padding Section 40.3: Format literals (f-string) Section 40.4: Float formatting Section 40.5: Named placeholders Section 40.6: String formatting with datetime Section 40.7: Formatting Numerical Values Section 40.8: Nested formatting Section 40.9: Format using Getitem and Getattr Section 40.10: Padding and truncating strings, combined Section 40.11: Custom formatting for a class Chapter 41: String Methods Section 41.1: Changing the capitalization of a string Section 41.2: str.translate: Translating characters in a string Section 41.3: str.format and f-strings: Format values into a string Section 41.4: String module's useful constants Section 41.5: Stripping unwanted leading/trailing characters from a string Section 41.6: Reversing a string Section 41.7: Split a string based on a delimiter into a list of strings Section 41.8: Replace all occurrences of one substring with another substring Section 41.9: Testing what a string is composed of Section 41.10: String Contains Section 41.11: Join a list of strings into one string Section 41.12: Counting number of times a substring appears in a string Section 41.13: Case insensitive string comparisons Section 41.14: Justify strings Section 41.15: Test the starting and ending characters of a string Section 41.16: Conversion between str or bytes data and unicode characters Chapter 42: Using loops within functions Section 42.1: Return statement inside loop in a function Chapter 43: Importing modules Section 43.1: Importing a module Section 43.2: The __all__ special variable Section 43.3: Import modules from an arbitrary filesystem location Section 43.4: Importing all names from a module Section 43.5: Programmatic importing Section 43.6: PEP8 rules for Imports Section 43.7: Importing specific names from a module Section 43.8: Importing submodules Section 43.9: Re-importing a module Section 43.10: __import__() function Chapter 44: Dierence between Module and Package Section 44.1: Modules Section 44.2: Packages Chapter 45: Math Module Section 45.1: Rounding: round, floor, ceil, trunc Section 45.2: Trigonometry Section 45.3: Pow for faster exponentiation Section 45.4: Infinity and NaN ("not a number") Section 45.5: Logarithms Section 45.6: Constants Section 45.7: Imaginary Numbers Section 45.8: Copying signs Section 45.9: Complex numbers and the cmath module Chapter 46: Complex math Section 46.1: Advanced complex arithmetic Section 46.2: Basic complex arithmetic Chapter 47: Collections module Section 47.1: collections.Counter Section 47.2: collections.OrderedDict Section 47.3: collections.defaultdict Section 47.4: collections.namedtuple Section 47.5: collections.deque Section 47.6: collections.ChainMap Chapter 48: Operator module Section 48.1: Itemgetter Section 48.2: Operators as alternative to an infix operator Section 48.3: Methodcaller Chapter 49: JSON Module Section 49.1: Storing data in a file Section 49.2: Retrieving data from a file Section 49.3: Formatting JSON output Section 49.4: `load` vs `loads`, `dump` vs `dumps` Section 49.5: Calling `json.tool` from the command line to pretty-print JSON output Section 49.6: JSON encoding custom objects Section 49.7: Creating JSON from Python dict Section 49.8: Creating Python dict from JSON Chapter 50: Sqlite3 Module Section 50.1: Sqlite3 - Not require separate server process Section 50.2: Getting the values from the database and Error handling Chapter 51: The os Module Section 51.1: makedirs - recursive directory creation Section 51.2: Create a directory Section 51.3: Get current directory Section 51.4: Determine the name of the operating system Section 51.5: Remove a directory Section 51.6: Follow a symlink (POSIX) Section 51.7: Change permissions on a file Chapter 52: The locale Module Section 52.1: Currency Formatting US Dollars Using the locale Module Chapter 53: Itertools Module Section 53.1: Combinations method in Itertools Module Section 53.2: itertools.dropwhile Section 53.3: Zipping two iterators until they are both exhausted Section 53.4: Take a slice of a generator Section 53.5: Grouping items from an iterable object using a function Section 53.6: itertools.takewhile Section 53.7: itertools.permutations Section 53.8: itertools.repeat Section 53.9: Get an accumulated sum of numbers in an iterable Section 53.10: Cycle through elements in an iterator Section 53.11: itertools.product Section 53.12: itertools.count Section 53.13: Chaining multiple iterators together Chapter 54: Asyncio Module Section 54.1: Coroutine and Delegation Syntax Section 54.2: Asynchronous Executors Section 54.3: Using UVLoop Section 54.4: Synchronization Primitive: Event Section 54.5: A Simple Websocket Section 54.6: Common Misconception about asyncio Chapter 55: Random module Section 55.1: Creating a random user password Section 55.2: Create cryptographically secure random numbers Section 55.3: Random and sequences: shue, choice and sample Section 55.4: Creating random integers and floats: randint, randrange, random, and uniform Section 55.5: Reproducible random numbers: Seed and State Section 55.6: Random Binary Decision Chapter 56: Functools Module Section 56.1: partial Section 56.2: cmp_to_key Section 56.3: lru_cache Section 56.4: total_ordering Section 56.5: reduce Chapter 57: The dis module Section 57.1: What is Python bytecode? Section 57.2: Constants in the dis module Section 57.3: Disassembling modules Chapter 58: The base64 Module Section 58.1: Encoding and Decoding Base64 Section 58.2: Encoding and Decoding Base32 Section 58.3: Encoding and Decoding Base16 Section 58.4: Encoding and Decoding ASCII85 Section 58.5: Encoding and Decoding Base85 Chapter 59: Queue Module Section 59.1: Simple example Chapter 60: Deque Module Section 60.1: Basic deque using Section 60.2: Available methods in deque Section 60.3: limit deque size Section 60.4: Breadth First Search Chapter 61: Webbrowser Module Section 61.1: Opening a URL with Default Browser Section 61.2: Opening a URL with Dierent Browsers Chapter 62: tkinter Section 62.1: Geometry Managers Section 62.2: A minimal tkinter Application Chapter 63: pyautogui module Section 63.1: Mouse Functions Section 63.2: Keyboard Functions Section 63.3: Screenshot And Image Recognition Chapter 64: Indexing and Slicing Section 64.1: Basic Slicing Section 64.2: Reversing an object Section 64.3: Slice assignment Section 64.4: Making a shallow copy of an array Section 64.5: Indexing custom classes: __getitem__, __setitem__ and __delitem__ Section 64.6: Basic Indexing Chapter 65: Plotting with Matplotlib Section 65.1: Plots with Common X-axis but dierent Y-axis : Using twinx() Section 65.2: Plots with common Y-axis and dierent X-axis using twiny() Section 65.3: A Simple Plot in Matplotlib Section 65.4: Adding more features to a simple plot : axis labels, title, axis ticks, grid, and legend Section 65.5: Making multiple plots in the same figure by superimposition similar to MATLAB Section 65.6: Making multiple Plots in the same figure using plot superimposition with separate plot commands Chapter 66: graph-tool Section 66.1: PyDotPlus Section 66.2: PyGraphviz Chapter 67: Generators Section 67.1: Introduction Section 67.2: Infinite sequences Section 67.3: Sending objects to a generator Section 67.4: Yielding all values from another iterable Section 67.5: Iteration Section 67.6: The next() function Section 67.7: Coroutines Section 67.8: Refactoring list-building code Section 67.9: Yield with recursion: recursively listing all files in a directory Section 67.10: Generator expressions Section 67.11: Using a generator to find Fibonacci Numbers Section 67.12: Searching Section 67.13: Iterating over generators in parallel Chapter 68: Reduce Section 68.1: Overview Section 68.2: Using reduce Section 68.3: Cumulative product Section 68.4: Non short-circuit variant of any/all Chapter 69: Map Function Section 69.1: Basic use of map, itertools.imap and future_builtins.map Section 69.2: Mapping each value in an iterable Section 69.3: Mapping values of dierent iterables Section 69.4: Transposing with Map: Using "None" as function argument (python 2.x only) Section 69.5: Series and Parallel Mapping Chapter 70: Exponentiation Section 70.1: Exponentiation using builtins: ** and pow() Section 70.2: Square root: math.sqrt() and cmath.sqrt Section 70.3: Modular exponentiation: pow() with 3 arguments Section 70.4: Computing large integer roots Section 70.5: Exponentiation using the math module: math.pow() Section 70.6: Exponential function: math.exp() and cmath.exp() Section 70.7: Exponential function minus 1: math.expm1() Section 70.8: Magic methods and exponentiation: builtin, math and cmath Section 70.9: Roots: nth-root with fractional exponents Chapter 71: Searching Section 71.1: Searching for an element Section 71.2: Searching in custom classes: __contains__ and __iter__ Section 71.3: Getting the index for strings: str.index(), str.rindex() and str.find(), str.rfind() Section 71.4: Getting the index list and tuples: list.index(), tuple.index() Section 71.5: Searching key(s) for a value in dict Section 71.6: Getting the index for sorted sequences: bisect.bisect_left() Section 71.7: Searching nested sequences Chapter 72: Sorting, Minimum and Maximum Section 72.1: Make custom classes orderable Section 72.2: Special case: dictionaries Section 72.3: Using the key argument Section 72.4: Default Argument to max, min Section 72.5: Getting a sorted sequence Section 72.6: Extracting N largest or N smallest items from an iterable Section 72.7: Getting the minimum or maximum of several values Section 72.8: Minimum and Maximum of a sequence Chapter 73: Counting Section 73.1: Counting all occurrence of all items in an iterable: collections.Counter Section 73.2: Getting the most common value(-s): collections.Counter.most_common() Section 73.3: Counting the occurrences of one item in a sequence: list.count() and tuple.count() Section 73.4: Counting the occurrences of a substring in a string: str.count() Section 73.5: Counting occurrences in numpy array Chapter 74: The Print Function Section 74.1: Print basics Section 74.2: Print parameters Chapter 75: Regular Expressions (Regex) Section 75.1: Matching the beginning of a string Section 75.2: Searching Section 75.3: Precompiled patterns Section 75.4: Flags Section 75.5: Replacing Section 75.6: Find All Non-Overlapping Matches Section 75.7: Checking for allowed characters Section 75.8: Splitting a string using regular expressions Section 75.9: Grouping Section 75.10: Escaping Special Characters Section 75.11: Match an expression only in specific locations Section 75.12: Iterating over matches using `re.finditer` Chapter 76: Copying data Section 76.1: Copy a dictionary Section 76.2: Performing a shallow copy Section 76.3: Performing a deep copy Section 76.4: Performing a shallow copy of a list Section 76.5: Copy a set Chapter 77: Context Managers (“with” Statement) Section 77.1: Introduction to context managers and the with statement Section 77.2: Writing your own context manager Section 77.3: Writing your own contextmanager using generator syntax Section 77.4: Multiple context managers Section 77.5: Assigning to a target Section 77.6: Manage Resources Chapter 78: The __name__ special variable Section 78.1: __name__ == '__main__' Section 78.2: Use in logging Section 78.3: function_class_or_module.__name__ Chapter 79: Checking Path Existence and Permissions Section 79.1: Perform checks using os.access Chapter 80: Creating Python packages Section 80.1: Introduction Section 80.2: Uploading to PyPI Section 80.3: Making package executable Chapter 81: Usage of "pip" module: PyPI Package Manager Section 81.1: Example use of commands Section 81.2: Handling ImportError Exception Section 81.3: Force install Chapter 82: pip: PyPI Package Manager Section 82.1: Install Packages Section 82.2: To list all packages installed using `pip` Section 82.3: Upgrade Packages Section 82.4: Uninstall Packages Section 82.5: Updating all outdated packages on Linux Section 82.6: Updating all outdated packages on Windows Section 82.7: Create a requirements.txt file of all packages on the system Section 82.8: Using a certain Python version with pip Section 82.9: Create a requirements.txt file of packages only in the current virtualenv Section 82.10: Installing packages not yet on pip as wheels Chapter 83: Parsing Command Line arguments Section 83.1: Hello world in argparse Section 83.2: Using command line arguments with argv Section 83.3: Setting mutually exclusive arguments with argparse Section 83.4: Basic example with docopt Section 83.5: Custom parser error message with argparse Section 83.6: Conceptual grouping of arguments with argparse.add_argument_group() Section 83.7: Advanced example with docopt and docopt_dispatch Chapter 84: Subprocess Library Section 84.1: More flexibility with Popen Section 84.2: Calling External Commands Section 84.3: How to create the command list argument Chapter 85: setup.py Section 85.1: Purpose of setup.py Section 85.2: Using source control metadata in setup.py Section 85.3: Adding command line scripts to your python package Section 85.4: Adding installation options Chapter 86: Recursion Section 86.1: The What, How, and When of Recursion Section 86.2: Tree exploration with recursion Section 86.3: Sum of numbers from 1 to n Section 86.4: Increasing the Maximum Recursion Depth Section 86.5: Tail Recursion - Bad Practice Section 86.6: Tail Recursion Optimization Through Stack Introspection Chapter 87: Type Hints Section 87.1: Adding types to a function Section 87.2: NamedTuple Section 87.3: Generic Types Section 87.4: Variables and Attributes Section 87.5: Class Members and Methods Section 87.6: Type hints for keyword arguments Chapter 88: Exceptions Section 88.1: Catching Exceptions Section 88.2: Do not catch everything! Section 88.3: Re-raising exceptions Section 88.4: Catching multiple exceptions Section 88.5: Exception Hierarchy Section 88.6: Else Section 88.7: Raising Exceptions Section 88.8: Creating custom exception types Section 88.9: Practical examples of exception handling Section 88.10: Exceptions are Objects too Section 88.11: Running clean-up code with finally Section 88.12: Chain exceptions with raise from Chapter 89: Raise Custom Errors / Exceptions Section 89.1: Custom Exception Section 89.2: Catch custom Exception Chapter 90: Commonwealth Exceptions Section 90.1: Other Errors Section 90.2: NameError: name '???' is not defined Section 90.3: TypeErrors Section 90.4: Syntax Error on good code Section 90.5: IndentationErrors (or indentation SyntaxErrors) Chapter 91: urllib Section 91.1: HTTP GET Section 91.2: HTTP POST Section 91.3: Decode received bytes according to content type encoding Chapter 92: Web scraping with Python Section 92.1: Scraping using the Scrapy framework Section 92.2: Scraping using Selenium WebDriver Section 92.3: Basic example of using requests and lxml to scrape some data Section 92.4: Maintaining web-scraping session with requests Section 92.5: Scraping using BeautifulSoup4 Section 92.6: Simple web content download with urllib.request Section 92.7: Modify Scrapy user agent Section 92.8: Scraping with curl Chapter 93: HTML Parsing Section 93.1: Using CSS selectors in BeautifulSoup Section 93.2: PyQuery Section 93.3: Locate a text after an element in BeautifulSoup Chapter 94: Manipulating XML Section 94.1: Opening and reading using an ElementTree Section 94.2: Create and Build XML Documents Section 94.3: Modifying an XML File Section 94.4: Searching the XML with XPath Section 94.5: Opening and reading large XML files using iterparse (incremental parsing) Chapter 95: Python Requests Post Section 95.1: Simple Post Section 95.2: Form Encoded Data Section 95.3: File Upload Section 95.4: Responses Section 95.5: Authentication Section 95.6: Proxies Chapter 96: Distribution Section 96.1: py2app Section 96.2: cx_Freeze Chapter 97: Property Objects Section 97.1: Using the @property decorator for read-write properties Section 97.2: Using the @property decorator Section 97.3: Overriding just a getter, setter or a deleter of a property object Section 97.4: Using properties without decorators Chapter 98: Overloading Section 98.1: Operator overloading Section 98.2: Magic/Dunder Methods Section 98.3: Container and sequence types Section 98.4: Callable types Section 98.5: Handling unimplemented behaviour Chapter 99: Polymorphism Section 99.1: Duck Typing Section 99.2: Basic Polymorphism Chapter 100: Method Overriding Section 100.1: Basic method overriding Chapter 101: User-Defined Methods Section 101.1: Creating user-defined method objects Section 101.2: Turtle example Chapter 102: String representations of class instances: __str__ and __repr__ methods Section 102.1: Motivation Section 102.2: Both methods implemented, eval-round-trip style __repr__() Chapter 103: Debugging Section 103.1: Via IPython and ipdb Section 103.2: The Python Debugger: Step-through Debugging with _pdb_ Section 103.3: Remote debugger Chapter 104: Reading and Writing CSV Section 104.1: Using pandas Section 104.2: Writing a TSV file Chapter 105: Writing to CSV from String or List Section 105.1: Basic Write Example Section 105.2: Appending a String as a newline in a CSV file Chapter 106: Dynamic code execution with `exec` and `eval` Section 106.1: Executing code provided by untrusted user using exec, eval, or ast.literal_eval Section 106.2: Evaluating a string containing a Python literal with ast.literal_eval Section 106.3: Evaluating statements with exec Section 106.4: Evaluating an expression with eval Section 106.5: Precompiling an expression to evaluate it multiple times Section 106.6: Evaluating an expression with eval using custom globals Chapter 107: PyInstaller - Distributing Python Code Section
دانلود کتاب Python® Notes for Professionals book