Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals
Overall
score
93%
Descriptor protocol and method binding (__get__ protocol, bound method creation)
Implements __get__ method
100%
100%
Returns bound callable
100%
100%
Handles None instance
100%
100%
Wraps original method
100%
100%
Records call information
100%
100%
Preserves return values
100%
100%
Scope and name resolution (LEGB rule, closures, UnboundLocalError)
Closure capture technique
100%
100%
Lambda closure capture
100%
100%
Nonlocal keyword usage
100%
100%
Global keyword usage
100%
100%
UnboundLocalError demonstration
100%
100%
String interning and identity (is vs ==)
Identity operator usage
100%
100%
Equality operator usage
100%
100%
String length check
100%
100%
Special character detection
100%
100%
ASCII-only validation
100%
100%
Return type correctness
100%
100%
Bytecode and compiler optimization (constant folding, AST vs peephole)
dis.dis() usage
100%
100%
compile() function
100%
100%
LOAD_CONST detection
100%
100%
co_consts access
0%
0%
Instruction parsing
100%
100%
Folding detection logic
100%
80%
Instruction counting
100%
100%
Class and object behavior (attributes, method identity, name mangling)
Attribute Type Detection
83%
93%
Method Identity Check
100%
100%
Name Mangling Logic
100%
100%
Error Handling
33%
40%
Exception handling (variable deletion, try-finally-return)
Exception variable capture
100%
100%
Variable deletion detection
100%
100%
Error handling structure
100%
100%
Try-finally-return structure
100%
100%
Except-finally-return structure
100%
100%
Finally override behavior
100%
100%
Closure and scope semantics (late binding, inspect.getclosurevars, generator scoping)
Uses inspect.getclosurevars
0%
80%
Late binding implementation
75%
100%
Early binding pattern
100%
100%
Generator scope analysis
60%
100%
Closure validation
80%
100%
Generator validation
100%
100%
Mutable vs immutable objects (default arguments, references)
Mutable default avoidance
100%
100%
Independent storage
100%
100%
Defensive copying
100%
100%
Correct execution
100%
100%
Unicode and character encoding (lookalike characters, raw string limitations)
Unicode code point extraction
100%
100%
Code point formatting
100%
100%
ASCII range detection
100%
100%
Lookalike mapping
100%
100%
Character position tracking
100%
100%
Risk classification logic
100%
100%
Numeric operations (banker's rounding, conversion limits, float precision)
Uses round() function
0%
0%
String length validation
80%
92%
Uses int() or float()
0%
100%
Float precision check
100%
80%
Install with Tessl CLI
npx tessl i tessl/pypi-wtfpython