or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/wtfpython@3.0.x
tile.json

tessl/pypi-wtfpython

tessl install tessl/pypi-wtfpython@3.0.0

Educational 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%

task.mdevals/scenario-1/

Safe Function Registry

A utility that manages a registry of callback functions with associated metadata, demonstrating proper handling of mutable default arguments and object references.

Capabilities

Function Registration

Register callback functions with optional metadata tags.

  • Registering a function without tags creates an empty tag list for that function @test
  • Registering a function with tags ["api", "v1"] stores those tags with the function @test
  • Registering multiple functions with no tags keeps their tag lists independent @test

Metadata Access

Access metadata associated with registered functions.

  • Getting metadata from a function registered without tags or config returns {"tags": [], "config": {}} @test
  • Getting metadata from a function registered with tags ["api", "v1"] returns those tags in the metadata @test
  • Getting metadata from a function registered with config {"timeout": 30} returns that config in the metadata @test
  • Modifying a returned metadata dict's tags list doesn't affect the stored tags for that function @test

Function Execution

Execute registered functions and return their results.

  • Calling a registered function with arguments passes them correctly and returns the result @test

Implementation

@generates

API

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."""
        pass

Dependencies { .dependencies }

wtfpython { .dependency }

Educational resource demonstrating Python's mutable default argument behavior and reference semantics.