I'm wanting to trigger a function inside the module for when the module itself is imported;
From what I've tested it seems that I can just check if __name__
isn't __main__
and use that as a solution; but I was wondering if there was a better way with some sort of import hook?
if __name__ != '__main__':
# I was imported
...
I'm wanting to modify an object that exists in the module for this specific case and only have it modified once.
I've had success with this; but am wondering if there's another way to approach this.
if __name__ == '__main__':
example = 0
else:
example = 1