exterminate icon indicating copy to clipboard operation
exterminate copied to clipboard

Inspiration: make the `class` statement create dicts instead of classes

Open encukou opened this issue 7 years ago • 0 comments

Have fun!

# Make the `class` statement create dicts


import builtins

def build_class(body_func, name):
    namespace = {}
    exec(body_func.__code__, namespace)

    for key in list(namespace.keys()):
        if key.startswith('__'):
            del namespace[key]

    return namespace

builtins.__build_class__ = build_class
class Foo:
    a = 1
    b = 2


print(Foo)

encukou avatar Mar 11 '17 16:03 encukou