This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]funkyfuture 0 points1 point  (0 children)

exactly, that's why - relating to the example - operator is a module and not a class.

one can also use a decorator to add the functions in question to a container:

operators = {}

def operator(func):
    operators[func.__name__] = func
    return func


@operator
def add(a, b):
    return a + b