or run

tessl search
Log in

Version

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

tessl/pypi-varname

tessl install tessl/pypi-varname@0.15.0

Dark magics about variable names in python

Agent Success

Agent success rate when using this tile

90%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.41x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-8/

Variable Name Tracker

A utility that enables objects to automatically capture and store the variable name they're assigned to during instantiation.

Capabilities

Self-naming object creation

  • Creating an instance and assigning it to a variable config stores "config" as the object's name @test
  • Creating an instance and assigning it to a variable database_connection stores "database_connection" as the object's name @test

Attribute assignment tracking

  • When an instance is assigned to an object's attribute like obj.setting, it captures "setting" as its name @test

Subscript assignment tracking

  • When an instance is assigned to a dictionary key like registry['handler'], it captures "handler" as its name @test

Implementation

@generates

API

class NamedObject:
    """
    A class that automatically captures the variable name it's assigned to.

    Instances store their assigned variable name in a `name` attribute.
    """

    def __init__(self):
        """Initialize a NamedObject and capture the assignment variable name."""
        pass

    @property
    def name(self) -> str:
        """Return the captured variable name."""
        pass

Dependencies { .dependencies }

varname { .dependency }

Provides variable name introspection capabilities.