Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals
Overall
score
93%
{
"context": "This criteria evaluates how well the engineer uses Python's descriptor protocol (__get__ method) to implement method tracking functionality. The focus is on proper implementation of the descriptor protocol to create bound methods that wrap original methods while maintaining correct binding behavior.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Implements __get__ method",
"description": "The TrackedMethod class implements the __get__ method that is part of Python's descriptor protocol",
"max_score": 30
},
{
"name": "Returns bound callable",
"description": "The __get__ method returns a callable that is properly bound to the instance (handles instance parameter correctly)",
"max_score": 25
},
{
"name": "Handles None instance",
"description": "The __get__ method handles the case when instance is None (accessed on class rather than instance) by returning self or the original method",
"max_score": 15
},
{
"name": "Wraps original method",
"description": "The implementation stores and calls the original method, preserving its functionality",
"max_score": 15
},
{
"name": "Records call information",
"description": "The bound callable records args and kwargs for each invocation in the instance's calls list",
"max_score": 10
},
{
"name": "Preserves return values",
"description": "The wrapped method returns the same value as the original method would return",
"max_score": 5
}
]
}Install with Tessl CLI
npx tessl i tessl/pypi-wtfpythondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10