Chapter 2: Python Intermediate¶
This chapter deepens your understanding of Python with topics like dynamic typing, numeric and string internals, iteration protocols, closures, scope rules, and performance fundamentals.
2.1 Variables and Naming¶
- Variables as Names
- Language Comparison
- Variable Assignment
- Shorthand Operators
- Simultaneous Assignment
- Chained Assignment
- Naming Constraints
- Unicode Identifiers
- Underscore Convention
- Bad Naming Practices
- Reserved Keywords
- Built-in Names
2.2 Dynamic Typing¶
2.3 Numeric Types Deep Dive¶
- int Python vs C
- int Bitwise Operations
- int Number Systems
- float Python vs C
- float IEEE 754 Standard
- float Numerical Errors
- float Special Values
- Type Promotion
2.4 Boolean Deep Dive¶
2.5 String Internals¶
- str ASCII and Unicode
- str UTF-8 Encoding
- str Encode and Decode
- str Immutability
- str Align Methods
- str Format Specifiers
- F-String Debugging
2.6 Composite Types Deep Dive¶
- Shallow and Deep Copying (copy module)
- Nested Data Structures
- tuple Optimization
- dict Internals (Hash Tables)
- dict Ordering Guarantees
- dict Merge Operators
- set Internals
- Time Complexity of Operations
2.7 Iteration Protocol¶
- Iterables and Iterators
- Generators and yield
- yield from
- StopIteration Mechanics
- Lazy Evaluation Patterns
- Iterator Chaining
2.8 Advanced Built-ins¶
2.9 Operators Deep Dive¶
- Operators Overview
- Arithmetic Operators
- Comparison Operators
- Sequence Comparison
- Identity Operators
- Membership Operators
- Precedence and Associativity
- Walrus Operator (:=)
2.10 Exceptions Deep Dive¶
2.11 File I/O Deep Dive¶
- Binary Files
- pickle and Serialization
- io.StringIO and io.BytesIO
- tempfile Module
- Encoding Issues
- shelve Module
2.12 Scope and Namespace¶
2.13 Function Parameters¶
- Call-by-Object-Reference
- Parameter Mechanisms
- Default Parameter Gotcha
- Parameter Passing
- Parameter Best Practices
2.14 Closures¶
- Closure Fundamentals
- Late Binding
- nonlocal and Mutation
- Scoping Rules
- Practical Patterns
- Closures Cheat Sheet