mean-teacher
mean-teacher copied to clipboard
what is the role of the export function?
def export(fn):
mod = sys.modules[fn.__module__]
if hasattr(mod, '__all__'):
mod.__all__.append(fn.__name__)
else:
mod.__all__ = [fn.__name__]
return fn
I don't understand the useful of the export function?
Hi,
It is just a way to avoid writing __all__ =
etc. at the top of the module. The architectures and data modules contain bunch of internal functions that we want to hide from the rest of the program. Within those modules, the functions that have @export
before them are visible to other modules, other functions are invisible.
Hope this helps.
Antti
Thanks !