I want to have a folder with some .py files so that everytime that I add a new file there, it would dynamically add the the new functions that I defined there to a dictionary so that I can use them by user input. Something like django does with views maybe? I can do this if it's on the same file. Like this.
#dicionario q guarda as referencias pras minhas funções
dictionary = dict()
#funcao anexadora.
def anexa_func(func):
dictionary[func.__qualname__] = func
return
@anexa_func
def nova_funcao():
print('joined in the function')
return
#mostrando q realmente salvou no dictionary
print(dictionary)
for key,value in dictionary.items():
dictionary[key]()
dictionary['nova_funcao']()
So i want to create a folder like "commands" and add new .py files with python functions inside that follow a syntax of what a "command" is, so i can invoke them with some args like first order functions.
if u guys run the program above, the output will be like this.
$ python main.py
{'new_function': function new_function at 0x7f8f678d6510}
joined in the function
joined in the function