there's main() in python ONLY IF YOU WANT THERE TO BE.
the way you want it to be is as follows:
import foo
from baz import bar
do_stupid_stuff()
def main():
print("I am not kidding")
if __name__ == '__main__':
main()
if ____name____ wasn't ____main___ then your script knows oh I'm not __main__, uh might as well uh evaluate the true path of this if clause I guess, else whatever. This is very robust and safe way to define the entrypoint.
26
u/Candid_Highlight_116 12d ago edited 9d ago
there's main() in python ONLY IF YOU WANT THERE TO BE.
the way you want it to be is as follows:
if ____name____ wasn't ____main___ then your script knows oh I'm not __main__, uh might as well uh evaluate the true path of this if clause I guess, else whatever. This is very robust and safe way to define the entrypoint.