M
- Mac OS X platform, GUIs, Introducing the Python Interpreter, Frozen Binaries, Starting an Interactive Session, Where to Run: Code Directories, Icon-Click Basics, IDLE Startup Details, Still Other Launch Options
-
- frozen binaries and, Frozen Binaries
- GUI support, GUIs
- icon clicks, Icon-Click Basics
- IDLE startup details, IDLE Startup Details
- installing Python, Introducing the Python Interpreter
- launch options, Still Other Launch Options
- system shell prompt, Starting an Interactive Session
- working directory, Where to Run: Code Directories
- macros, decorators versus, Why Decorators?
- __main__ module, Mixed Usage Modes: __name__ and __main__–Unit Tests with __name__, Exploring Shelves Interactively
- manager functions, Decorators Versus Manager Functions, The Downside of “Helper” Functions–The Downside of “Helper” Functions
- map built-in function, Comprehensions, List Iteration and Comprehensions, Loop Coding Techniques, Parallel Traversals: zip and map–Dictionary construction with zip, Parallel Traversals: zip and map–Dictionary construction with zip, map equivalence in Python 2.X, Other Iteration Contexts, New Iterables in Python 3.X, The map, zip, and filter Iterables, Mapping Functions over Iterables: map–Mapping Functions over Iterables: map, List Comprehensions Versus map, On the other hand: performance, conciseness, expressiveness, Generator expressions versus map–Generator expressions versus map, Example: Emulating zip and map with Iteration Tools–Coding your own zip(...) and map(None, ...), Timing Results–The impact of function calls: map, A win for map and a rare loss for PyPy, Timing Calls
-
- benchmarking, A win for map and a rare loss for PyPy
- generator expressions versus, Generator expressions versus map–Generator expressions versus map
- homegrown timing module and, Timing Results–The impact of function calls: map
- iteration and, Other Iteration Contexts, New Iterables in Python 3.X, The map, zip, and filter Iterables, Mapping Functions over Iterables: map–Mapping Functions over Iterables: map, Example: Emulating zip and map with Iteration Tools–Coding your own zip(...) and map(None, ...)
- list comprehensions versus, Comprehensions, List Iteration and Comprehensions, List Comprehensions Versus map, On the other hand: performance, conciseness, expressiveness
- loop coding techniques and, Loop Coding Techniques, Parallel Traversals: zip and map–Dictionary construction with zip
- parallel traversals, Parallel Traversals: zip and map–Dictionary construction with zip
- timing calls example, Timing Calls
- version considerations, map equivalence in Python 2.X
- mapattrs module, Room for improvement: MRO, slots, GUIs
- mapping operations, Dictionaries, Mapping Operations, Missing Keys: if Tests–Missing Keys: if Tests, Missing Keys: if Tests–Missing Keys: if Tests, Preview: Mapping values to keys, Preview: Mapping values to keys, Mapping Functions over Iterables: map–Mapping Functions over Iterables: map, Example: Mapping Attributes to Inheritance Sources–Example: Mapping Attributes to Inheritance Sources
-
- about, Dictionaries
- dictionaries and, Mapping Operations, Missing Keys: if Tests–Missing Keys: if Tests, Preview: Mapping values to keys
- functions and, Mapping Functions over Iterables: map–Mapping Functions over Iterables: map
- mapping attributes to inheritance sources, Example: Mapping Attributes to Inheritance Sources–Example: Mapping Attributes to Inheritance Sources
- mapping values to keys, Preview: Mapping values to keys
- missing keys, Missing Keys: if Tests–Missing Keys: if Tests
- math module, Numbers, Floor versus truncation, Floor versus truncation, Other Built-in Numeric Tools
-
- about, Numbers
- built-in numeric tools, Other Built-in Numeric Tools
- floor function, Floor versus truncation
- trunc function, Floor versus truncation
- mathematical operations, Numbers, Numbers, Python Expression Operators, Division: Classic, Floor, and True–Why does truncation matter?
-
- about, Numbers
- division, Division: Classic, Floor, and True–Why does truncation matter?
- expression operators, Python Expression Operators
- nesting, Numbers
- Matlab numeric programming system, Why Do People Use Python?, Nesting
- matrixes, Indexing, Slicing, and Matrixes, Example: List Comprehensions and Matrixes–Example: List Comprehensions and Matrixes
-
- list comprehensions and, Example: List Comprehensions and Matrixes–Example: List Comprehensions and Matrixes
- nested lists and, Indexing, Slicing, and Matrixes
- max built-in function, Other Built-in Numeric Tools, Other Iteration Contexts
- membership, Missing Keys: if Tests, Other Core Types, Other Common String Methods in Action, Basic Dictionary Operations, Membership: __contains__, __iter__, and __getitem__–Membership: __contains__, __iter__, and __getitem__
-
- in operator and, Missing Keys: if Tests, Other Core Types, Other Common String Methods in Action, Basic Dictionary Operations
- operator overloading and, Membership: __contains__, __iter__, and __getitem__–Membership: __contains__, __iter__, and __getitem__
- memory management, It’s Powerful, Nesting Revisited, Objects Are Garbage-Collected, Changing Strings I, Why generator expressions?, How Python Stores Strings in Memory
-
- automatic, It’s Powerful
- garbage collection, Nesting Revisited, Objects Are Garbage-Collected, Changing Strings I
- generator expressions and, Why generator expressions?
- storing strings, How Python Stores Strings in Memory
- metaclasses, Attribute Tree Construction, Why the lookup change?, Decorators and Metaclasses: Part 1, A First Look at Class Decorators and Metaclasses–A First Look at Class Decorators and Metaclasses, Metaclasses, To Metaclass or Not to Metaclass–Metaclasses Versus Class Decorators: Round 1, Metaclasses Versus Class Decorators: Round 1–Metaclasses Versus Class Decorators: Round 1, The Metaclass Model–Class Statement Protocol, Metaclasses Are Subclasses of Type, Class Statement Protocol, Declaring Metaclasses–Metaclass Dispatch in Both 3.X and 2.X, Declaration in 3.X–Metaclass Dispatch in Both 3.X and 2.X, Coding Metaclasses–Overloading class creation calls with metaclasses, Customizing Construction and Initialization, Using simple factory functions, Overloading class creation calls with normal classes–Overloading class creation calls with metaclasses, Inheritance and Instance–The built-ins special case, Inheritance and Instance–The built-ins special case, Metaclass Versus Superclass, The descriptors special case, The built-ins special case–The built-ins special case, Metaclass Methods–Metaclasses Versus Class Decorators: Round 3 (and Last), Operator Overloading in Metaclass Methods, Example: Adding Methods to Classes–Metaclasses Versus Class Decorators: Round 3 (and Last), Metaclasses Versus Class Decorators: Round 2–Metaclass and class decorator equivalence?, Managing instances instead of classes–Managing instances instead of classes, Metaclasses Versus Class Decorators: Round 3 (and Last)–Metaclasses Versus Class Decorators: Round 3 (and Last)
-
- about, Metaclasses
- built-in object types and, The built-ins special case–The built-ins special case
- call pattern issues and, Why the lookup change?
- class decorators and, Decorators and Metaclasses: Part 1, A First Look at Class Decorators and Metaclasses–A First Look at Class Decorators and Metaclasses, Metaclasses Versus Class Decorators: Round 1–Metaclasses Versus Class Decorators: Round 1, Metaclasses Versus Class Decorators: Round 2–Metaclass and class decorator equivalence?, Metaclasses Versus Class Decorators: Round 3 (and Last)–Metaclasses Versus Class Decorators: Round 3 (and Last)
- class statement and, Class Statement Protocol
- coding, Coding Metaclasses–Overloading class creation calls with metaclasses
- customizing construction and initialization, Customizing Construction and Initialization
- declaring, Declaring Metaclasses–Metaclass Dispatch in Both 3.X and 2.X
- descriptors and, The descriptors special case
- factory functions and, Using simple factory functions
- inheritance and, Attribute Tree Construction, Inheritance and Instance–The built-ins special case
- instances and, Inheritance and Instance–The built-ins special case, Managing instances instead of classes–Managing instances instead of classes
- methods in, Metaclass Methods–Metaclasses Versus Class Decorators: Round 3 (and Last)
- model overview, The Metaclass Model–Class Statement Protocol
- operator overloading and, Overloading class creation calls with normal classes–Overloading class creation calls with metaclasses, Operator Overloading in Metaclass Methods
- superclasses versus, Metaclass Versus Superclass
- type object and, Metaclasses Are Subclasses of Type
- usage considerations, To Metaclass or Not to Metaclass–Metaclasses Versus Class Decorators: Round 1
- usage examples, Example: Adding Methods to Classes–Metaclasses Versus Class Decorators: Round 3 (and Last)
- version considerations, Declaration in 3.X–Metaclass Dispatch in Both 3.X and 2.X
- metafunctions, Decorators and Metaclasses: Part 1–Function Decorator Basics, Usage
- metaprograms, Example: Modules Are Objects–Example: Modules Are Objects
- method resolution order, Augmenting Methods: The Good Way (see MRO)
- methods, Type-Specific Methods, Type-Specific Operations, Files, Built-in Numeric Tools, String Basics, String Methods–The Original string Module’s Functions (Gone in 3.X), Method Call Syntax, The Original string Module’s Functions (Gone in 3.X)–The Original string Module’s Functions (Gone in 3.X), String Formatting Method Calls–Functions versus expressions: A minor convenience, List method calls–Other common list methods, Dictionaries, More Dictionary Methods–More Dictionary Methods, Conversions, methods, and immutability–Conversions, methods, and immutability, Files in Action, Expression Statements, Using List Comprehensions on Files, Scopes: lambdas Can Be Nested Too, Method Calls, A First Example, Classes Can Intercept Python Operators, Step 2: Adding Behavior Methods–Coding Methods, Step 2: Adding Behavior Methods, Coding Methods–Coding Methods, Augmenting Methods: The Bad Way–Augmenting Methods: The Good Way, Methods, Method Example, Calling Superclass Constructors, Other Method Call Possibilities, Other Method Call Possibilities, Right-Side and In-Place Uses: __radd__ and __iadd__–In-Place Addition, Methods Are Objects: Bound or Unbound–Other callables, Methods Are Objects: Bound or Unbound–Other callables, Methods Are Objects: Bound or Unbound–Other callables, Static Methods in 2.X and 3.X, Static Methods in 2.X and 3.X, Scopes in Methods and Classes, Providing Exception Methods–Providing Exception Methods, Class Blunders I: Decorating Methods–Using descriptors to decorate methods, Metaclass Methods–Metaclasses Versus Class Decorators: Round 3 (and Last), Example: Adding Methods to Classes–Metaclass and class decorator equivalence?, Example: Applying Decorators to Methods–Metaclasses Versus Class Decorators: Round 3 (and Last)
-
- (see also operator overloading)
- about, Method Calls, Methods
- adding, Step 2: Adding Behavior Methods–Coding Methods, Example: Adding Methods to Classes–Metaclass and class decorator equivalence?
- attribute fetches, Method Call Syntax
- augmenting, Augmenting Methods: The Bad Way–Augmenting Methods: The Good Way
- binary operator, Right-Side and In-Place Uses: __radd__ and __iadd__–In-Place Addition
- bound, Scopes: lambdas Can Be Nested Too, Methods Are Objects: Bound or Unbound–Other callables, Static Methods in 2.X and 3.X
- chaining, Using List Comprehensions on Files
- coding, Coding Methods–Coding Methods
- decorators and, Class Blunders I: Decorating Methods–Using descriptors to decorate methods, Example: Applying Decorators to Methods–Metaclasses Versus Class Decorators: Round 3 (and Last)
- dictionary, Dictionaries, More Dictionary Methods–More Dictionary Methods
- exception handler, Providing Exception Methods–Providing Exception Methods
- expressions and, Expression Statements
- file, Files, Files in Action
- functions and, A First Example
- instance, Other Method Call Possibilities
- list, Type-Specific Operations, List method calls–Other common list methods
- metaclass, Metaclass Methods–Metaclasses Versus Class Decorators: Round 3 (and Last)
- number-specific, Built-in Numeric Tools
- as objects, Methods Are Objects: Bound or Unbound–Other callables
- scopes in, Scopes in Methods and Classes
- static, Other Method Call Possibilities
- string, Type-Specific Methods, String Basics, String Methods–The Original string Module’s Functions (Gone in 3.X), The Original string Module’s Functions (Gone in 3.X)–The Original string Module’s Functions (Gone in 3.X)
- string formatting, String Formatting Method Calls–Functions versus expressions: A minor convenience
- superclass constructors, Calling Superclass Constructors
- tuple, Conversions, methods, and immutability–Conversions, methods, and immutability
- unbound, Methods Are Objects: Bound or Unbound–Other callables, Static Methods in 2.X and 3.X
- underscores in, Classes Can Intercept Python Operators
- usage examples, Method Example
- microthreads, Stackless: Python for concurrency
- min built-in function, Other Built-in Numeric Tools, Other Iteration Contexts, Timing Module: Homegrown
- missing keys, Missing Keys: if Tests–Missing Keys: if Tests, Avoiding missing-key errors
- mix-in classes, Multiple Inheritance: “Mix-in” Classes–Room for improvement: MRO, slots, GUIs, Coupling: Application to mix-in classes–Coupling: Application to mix-in classes
- __mod__ method, Method Calls
- module search path, Usage Notes: import and reload, The Module Search Path–Optimized byte code files, Module Lookup Rules Summary, Changing the Module Search Path–Changing the Module Search Path, Path files, Running modules on the search path
-
- about, Usage Notes: import and reload, The Module Search Path–Optimized byte code files, Path files
- changing, Changing the Module Search Path–Changing the Module Search Path
- lookup rules summary, Module Lookup Rules Summary
- running modules, Running modules on the search path
- modules, System Command Lines and Files, System Command Lines and Files, System Command Lines and Files, Import and Reload Basics–The Grander Module Story: Attributes, The Grander Module Story: Attributes–Modules and namespaces, Modules and namespaces, Usage Notes: import and reload, Usage Notes: import and reload, Usage Notes: import and reload, Using exec to Run Module Files, Usage Notes: IDLE, Usage Notes: IDLE, Embedding Calls, The Python Conceptual Hierarchy, The Python Conceptual Hierarchy, Python’s Core Data Types, Numbers, Scope Details, Modules: The Big Picture–Why Use Modules?, Why Use Modules?, Python Program Architecture–Standard Library Modules, How to Structure a Program–Imports and Attributes, Byte Code Files: __pycache__ in Python 3.2+–Byte Code File Models in Action, The Module Search Path–Optimized byte code files, Test Your Knowledge: Quiz, Module Creation–Other Kinds of Modules, Other Kinds of Modules, Module Usage–When import is required, The from Statement, import and from Are Assignments–When import is required, Module Namespaces–Namespace Nesting, Reloading Modules–reload Example, Test Your Knowledge: Quiz, Module Packages, Module Packages, Module Lookup Rules Summary, Module Design Concepts–Module Design Concepts, Data Hiding in Modules, Enabling Future Language Features: __future__, Mixed Usage Modes: __name__ and __main__–Unit Tests with __name__, Example: Dual Mode Code–Docstrings: Module Documentation at Work, Changing the Module Search Path–Changing the Module Search Path, The as Extension for import and from, Example: Modules Are Objects–Example: Modules Are Objects, Example: Transitive Module Reloads–Testing reload variants, Module Gotchas–Recursive from Imports May Not Work, Module Name Clashes: Package and Package-Relative Imports, Statement Order Matters in Top-Level Code, from Copies Names but Doesn’t Link, Test Your Knowledge: Quiz, Classes and Instances, Classes Are Attributes in Modules, Classes Are Attributes in Modules, Example, Classes Versus Modules, Usage variation: Running on larger modules, Path files, Running modules on the search path
-
- (see also from statement; import statement; packages)
- about, System Command Lines and Files, Python’s Core Data Types, Numbers, Modules: The Big Picture–Why Use Modules?
- as extension for import/from statements, The as Extension for import and from
- attributes and, The Grander Module Story: Attributes–Modules and namespaces, How to Structure a Program–Imports and Attributes, Classes Are Attributes in Modules
- byte code files, Byte Code Files: __pycache__ in Python 3.2+–Byte Code File Models in Action
- classes and, Classes and Instances, Classes Are Attributes in Modules, Example, Classes Versus Modules
- common usage mistakes, Usage Notes: import and reload, Usage Notes: IDLE
- copying names, The from Statement, import and from Are Assignments–When import is required, from Copies Names but Doesn’t Link
- creating, Module Creation–Other Kinds of Modules
- data hiding in, Data Hiding in Modules
- design concepts, Module Design Concepts–Module Design Concepts
- dual mode code example, Example: Dual Mode Code–Docstrings: Module Documentation at Work
- embedding calls, Embedding Calls
- enabling future language features, Enabling Future Language Features: __future__
- exec built-in function and, Using exec to Run Module Files
- extension, Other Kinds of Modules
- importing, Module Packages
- mixed usage modes, Mixed Usage Modes: __name__ and __main__–Unit Tests with __name__
- module search path, Usage Notes: import and reload, The Module Search Path–Optimized byte code files, Module Lookup Rules Summary, Changing the Module Search Path–Changing the Module Search Path, Path files, Running modules on the search path
- name clashes, Module Name Clashes: Package and Package-Relative Imports
- namespaces and, Modules and namespaces, Why Use Modules?, Module Namespaces–Namespace Nesting
- as objects, Example: Modules Are Objects–Example: Modules Are Objects
- potential gotchas, Module Gotchas–Recursive from Imports May Not Work
- programs and, System Command Lines and Files, The Python Conceptual Hierarchy
- Python program architecture and, Python Program Architecture–Standard Library Modules
- quiz questions and answers, Test Your Knowledge: Quiz, Test Your Knowledge: Quiz, Test Your Knowledge: Quiz
- reloading, Import and Reload Basics–The Grander Module Story: Attributes, Usage Notes: import and reload, Usage Notes: IDLE, Reloading Modules–reload Example, Example: Transitive Module Reloads–Testing reload variants
- scope considerations, Scope Details
- statements and, System Command Lines and Files, The Python Conceptual Hierarchy, Statement Order Matters in Top-Level Code
- usage considerations, Module Usage–When import is required, Usage variation: Running on larger modules
- modulus operator, Formatting Expression Basics
- mod_python package, Internet Scripting
- MongoDB database, Nesting Revisited
- movie database example, Example: Movie Database–Preview: Mapping values to keys
- MRO (method resolution order), Augmenting Methods: The Good Way, Multiple Inheritance: “Mix-in” Classes, Room for improvement: MRO, slots, GUIs, New-Style Class Changes, Diamond Inheritance Change–Example: Mapping Attributes to Inheritance Sources, Cooperative Multiple Inheritance Method Dispatch–Coupling: Application to mix-in classes
-
- about, New-Style Class Changes, Diamond Inheritance Change–Example: Mapping Attributes to Inheritance Sources
- new-style classes and, Multiple Inheritance: “Mix-in” Classes, Room for improvement: MRO, slots, GUIs
- super built-in function and, Augmenting Methods: The Good Way, Cooperative Multiple Inheritance Method Dispatch–Coupling: Application to mix-in classes
- __mro__ attribute, Room for improvement: MRO, slots, GUIs, New-Style Class Changes, More on the MRO: Method Resolution Order–Tracing the MRO, Python’s inheritance algorithm: The simple version
-
- about, Room for improvement: MRO, slots, GUIs, New-Style Class Changes, More on the MRO: Method Resolution Order–Tracing the MRO
- inheritance and, Python’s inheritance algorithm: The simple version
- multiline block strings, Triple Quotes Code Multiline Block Strings–Triple Quotes Code Multiline Block Strings
- multiline statements, Entering multiline statements (see compound statements)
- multiple context managers, Multiple Context Managers in 3.1, 2.7, and Later–Multiple Context Managers in 3.1, 2.7, and Later
- multiple inheritance, Coding Class Trees, Multiple Inheritance: “Mix-in” Classes–Room for improvement: MRO, slots, GUIs, New-Style Class Changes, Diamond Inheritance Change–Example: Mapping Attributes to Inheritance Sources, Odd semantics: A magic proxy in Python 3.X–Pitfall: Adding multiple inheritance naively, Cooperative Multiple Inheritance Method Dispatch–Customization: Same-argument constraints, Multiple Inheritance: Order Matters–Multiple Inheritance: Order Matters
-
- about, Coding Class Trees
- class gotchas, Multiple Inheritance: Order Matters–Multiple Inheritance: Order Matters
- diamond patterns of, New-Style Class Changes, Diamond Inheritance Change–Example: Mapping Attributes to Inheritance Sources
- mix-in classes and, Multiple Inheritance: “Mix-in” Classes–Room for improvement: MRO, slots, GUIs
- super built-in function and, Odd semantics: A magic proxy in Python 3.X–Pitfall: Adding multiple inheritance naively, Cooperative Multiple Inheritance Method Dispatch–Customization: Same-argument constraints
- multiple instances, Classes Generate Multiple Instance Objects–A First Example, Supporting multiple instances, Class Blunders II: Retaining Multiple Instances
- multiple-target assignments, Assignment Statement Forms, Multiple-Target Assignments–Multiple-target assignment and shared references
- multiplication (*) operator, Numbers, Sequence Operations, Basic Operations, Basic List Operations
-
- multiplying numbers, Numbers
- repeating lists, Basic List Operations
- repeating strings, Sequence Operations, Basic Operations
- multithreading, Program Design: Minimize Global Variables, Why generator functions?
- multiway branching in if statements, Multiway Branching–Handling larger actions, Multiway branch switches: The finale
- mutable objects, Lists, Dictionaries, Lists, Avoiding Mutable Argument Changes, Combining keywords and defaults, Defaults and Mutable Objects–Defaults and Mutable Objects, Changing mutables in modules
-
- avoiding argument changes, Avoiding Mutable Argument Changes
- changing in modules, Changing mutables in modules
- default values for arguments, Combining keywords and defaults
- dictionaries as, Dictionaries
- function gotchas, Defaults and Mutable Objects–Defaults and Mutable Objects
- lists as, Lists, Lists