Avatar ·

What does if __name__ == "__main__" do?

📁 Decorator, method, Multiprocessing, Parsing

n

What happens during the call if __name__ == "__main__":?

n
# Threading examplenimport time, threadnndef myfunction(string, sleeptime, lock, *args):n    while 1:n        lock.acquire()n        time.sleep(sleeptime)n        lock.release()n        time.sleep(sleeptime)nif __name__ == "__main__":n    lock = thread.allocate_lock()n    threa