Step 3 / Select topic Python Medium
What this bank covers
- Extended slicing: `seq[start:stop:step]`
- Comprehension scoping
- Late-binding closures
- Variadic positional parameters
- The context manager protocol
- Truthiness of containers
- The mutable default argument trap
- str.join(iterable)
- Variadic keyword parameters
- Format specification mini-language
- Generator functions are lazy
- Generator expressions vs list comprehensions
- Decorators are just function application
- functools.wraps
- Unpacking an iterable at a call site
- Unpacking a dict into keyword arguments
- f-strings evaluate arbitrary expressions
- Self-documenting f-strings
- Dict comprehensions
- Empty `{}` is a dict, not a set
- Multiple context managers in one `with`
- contextlib.contextmanager
- Exception chaining
- Custom exception classes
- @property
- Property setters
- @staticmethod
- @classmethod as alternate constructor
- enumerate() with a custom start
- zip() truncates to the shortest iterable
- sorted(..., key=...)
- sorted(..., reverse=True)
- collections.Counter
- collections.defaultdict
- collections.namedtuple
- itertools.chain
- itertools.combinations
- Shallow copy vs deep copy
- __repr__ as the fallback for __str__
- Default equality is identity
- functools.total_ordering
- Extended (starred) unpacking
- Walrus operator inside a comprehension filter
- Type hints are not enforced at runtime
- typing.Optional
- assert can be optimized away
- The global keyword
- The nonlocal keyword
- str.encode() and bytes.decode()
- is vs ==
- Hashability and dict keys
- Mixing positional and keyword arguments
- Chained comparisons
- Conditional (ternary) expressions
- Chained assignment shares one object
- Swapping via tuple unpacking
- String repetition with *
- List multiplication aliases inner mutable objects
- all() and any()
- map() is lazy
- filter() with None as the predicate
- lambda expression syntax
- dict.get(key, default)
- dict.setdefault(key, default)
- Dict union with |
- Set intersection operator
- frozenset immutability
- Strings are immutable
- list.append vs list.extend
- list.pop(index)
- del statement vs pop()
- Slice assignment can change list length
- Negative indexing
- range() is lazy
- Manual iterator protocol
- try/except/else
- Catching multiple exception types
- Bare raise re-raises the active exception
- pathlib.Path
- json.dumps / json.loads
- datetime + timedelta arithmetic
- random.seed()
- str.strip() default behavior
- startswith()/endswith() accept a tuple
- in operator on dicts checks keys
- Duck typing via __len__
- abc.ABC and @abstractmethod
- Class attributes vs instance attributes
- super() in __init__
- Nested unpacking
- Method chaining via returning self
- Comprehension with a filter clause
- Conditional expression inside a comprehension
- Nested (flattening) comprehension
- functools.reduce
- functools.partial
- zip(*pairs) as an unzip idiom
- Old-style % string formatting
- Returning multiple values as a tuple
- Keyword-only arguments with a bare *
- Mutable default arguments
- Changing a dict while iterating over it
- Queues: deque.popleft() versus list.pop(0)
- Lazy evaluation with next()