3 ms·
Check out the module “q”! It’s callable, its author talked about how great it would be to have a module level __call__ because the way it was made callable is s
by scrollaway 2y ago
Check out the module “q”! It’s callable, its author talked about how great it would be to have a module level __call__ because the way it was made callable is super wonky.
- enriquto 2y ago> the way it was made callable is super wonky. why do you say it's wonky? it's just sys.modules[__name__] = wat According to the official python documentation [0] of sys.modules: > This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of modules and other tricks. Thus, the modules dictionary is being used as intended, and it has the desired effect. Nothing wonky about that. Of course, a __call__ method would be better because you could still keep the other functions inside the module. But for a single-function import like "wat" it seems quite natural and sane. [0] https://docs.python.org/fr/3/library/sys.html https://docs.python.org/fr/3/library/sys.html