Class Decorators

Hard Design Patterns & Final Challenges PRO
🔒 Login to Unlock

Problem Statement

Create a class decorator `@add_repr` that dynamically injects a `__repr__` method into a class, returning the string ‘Class: [ClassName]’. Apply it to a newly defined `TestModule` class. Instantiate it and print using `repr()`.

Input Format

None

Output Format

Print the injected representation.

Constraints

None

Sample Output

Class: TestModule

Explanation

Class decorators operate on entire classes instead of functions, allowing powerful metaprogramming and dynamic attribute injection.

Starter Code

def add_repr(cls):
    # Inject __repr__ here
    pass

# @add_repr
class TestModule:
    pass

if __name__ == '__main__':
    # Instantiate and print representation
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used