Some Python code samples which, similar to others here, are by no means exhaustive but just some things I wanted to write down.
Logic
Tuples
Strings
Ternary Operators
Ranges
Lists
Dictonaries
Sets
Protocols
- Container supports
x in y
and x not in y
- Sized supports
num = len(x)
- Iterable supports
iterator = iter(iterable)
- Iterator supports
item = next(iterator)
- Sequence supports:
item = seq[index]
index = seq.index(item)
num = seq.count(item)
reversed(seq)
- Mutable Sequence
- Mutable Set
- Mutable Mapping
Exception Handling
Comprehensions
Iterators
Generators
Classes
Using Files
Bitwise operations
Bytes
Reading from a file by URL with ‘closing’ context manager
Unittest
Python Debugger
Distutils
Current time in milliseconds