CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-wtfpython

Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals

Overall
score

93%

Overview
Eval results
Files

rubric.jsonevals/scenario-5/

{
  "context": "This criteria evaluates how well the engineer uses Python's introspection capabilities and demonstrates understanding of class attributes, method identity, and name mangling mechanisms. The focus is on correctly using Python's built-in functions and operators to analyze object-oriented behavior.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Attribute Type Detection",
      "description": "Correctly uses __dict__, vars(), hasattr(), or type() to determine whether an attribute belongs to the class or instance. Checks class namespace (via cls.__dict__ or type(obj).__dict__) versus instance namespace (via obj.__dict__) to distinguish attribute locations.",
      "max_score": 30
    },
    {
      "name": "Method Identity Check",
      "description": "Correctly uses the 'is' operator for identity comparison and '==' operator for equality comparison. Returns both comparison results in a dictionary format. Properly retrieves method references using getattr() or direct attribute access.",
      "max_score": 25
    },
    {
      "name": "Name Mangling Logic",
      "description": "Implements the name mangling transformation correctly: checks if attribute name starts with '__' but doesn't end with '__', and formats result as '_ClassName__attributename'. Uses string methods like startswith(), endswith(), and string formatting to construct the mangled name.",
      "max_score": 30
    },
    {
      "name": "Error Handling",
      "description": "Properly handles edge cases such as non-existent attributes using hasattr() checks, AttributeError exception handling, or defensive programming. Returns appropriate values ('neither', None, or raises informative errors) when attributes don't exist.",
      "max_score": 15
    }
  ]
}

Install with Tessl CLI

npx tessl i tessl/pypi-wtfpython

tile.json