🔶 Python: `if __name__ == '__main__'`
if __name__ == '__main__':
main()
What it does: Checks if the file is being run directly (not imported).
- Run
python script.py→__name__is'__main__'→ code inside executes - Another file does
import script→__name__is'script'→ code inside is SKIPPED
Why it exists: So you can write a module that's both importable (other files use its functions) AND runnable as a standalone script.