Tag

main

1 views collected around this technical thread.

Test Development Learning Exchange
Test Development Learning Exchange
Jun 11, 2024 · Fundamentals

Deep Understanding of __main__ and __name__ in Python

This article explains the special built‑in identifiers __main__ and __name__ in Python, describing how they indicate a module's execution context, how to use them to separate script and library code, and provides multiple practical code examples.

Module__name__code
0 likes · 6 min read
Deep Understanding of __main__ and __name__ in Python
IT Services Circle
IT Services Circle
May 29, 2024 · Fundamentals

Understanding the __name__ Variable in Python Scripts

This article explains how the __name__ variable is set when running Python scripts directly or importing them, demonstrates its behavior with multiple .py files, shows how unintended code can be executed, and introduces the if __name__ == '__main__' guard to control execution.

ImportPython__name__
0 likes · 6 min read
Understanding the __name__ Variable in Python Scripts