tessl install tessl/pypi-wtfpython@3.0.0Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals
Agent Success
Agent success rate when using this tile
93%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.06x
Baseline
Agent success rate without this tile
88%
A utility that manages a registry of callback functions with associated metadata, demonstrating proper handling of mutable default arguments and object references.
Register callback functions with optional metadata tags.
["api", "v1"] stores those tags with the function @testAccess metadata associated with registered functions.
{"tags": [], "config": {}} @test["api", "v1"] returns those tags in the metadata @test{"timeout": 30} returns that config in the metadata @testExecute registered functions and return their results.
@generates
class FunctionRegistry:
"""Manages a registry of callback functions with metadata."""
def register(self, name: str, func: callable, tags: list = None, config: dict = None) -> None:
"""
Register a callback function with optional tags and config.
Args:
name: Unique identifier for the function
func: The callable to register
tags: Optional list of string tags (creates new empty list if None)
config: Optional configuration dict (creates new empty dict if None)
"""
pass
def get_metadata(self, name: str) -> dict:
"""
Get the metadata for a registered function.
Returns:
dict: Dictionary with 'tags' (list) and 'config' (dict) keys
"""
pass
def execute(self, name: str, *args, **kwargs):
"""Execute a registered function with the given arguments."""
passEducational resource demonstrating Python's mutable default argument behavior and reference semantics.