---
title: "Discussion on \"What does if __name__ ='main' do in Python?\" | Hashnode"
description: "Discussion on \"What does if __name__ ='main' do in Python?\". You might have seen this line of code if __name__==\"__main__\": a lot in Python scripts, without knowing what is it's actual purpose. Don't worry because in this short blog we will be discussing this\nWhen you directly run a program or script, Python a..."
url: "https://hashnode.com/posts/what-does-if-name-main-do-in-python/66a68d941e2c186daee3c880"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [What does if \_\_name\_\_ ='main' do in Python?](https://kaustubhupadhy.hashnode.dev/what-does-if-name-main-do-in-python?utm_source=hashnode&utm_medium=feed)

You might have seen this line of code if \_\_name\_\_=="\_\_main\_\_": a lot in Python scripts, without knowing what is it's actual purpose. Don't worry because in this short blog we will be discussing this When you directly run a program or script, Python a...

Jul 28, 2024 · 2 min read · kaustubhupadhy.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#python-beginner](https://hashnode.com/tag/python-beginner)

## Written by

[Kaustubh Upadhyay](https://hashnode.com/@Kupadhy)

@Kupadhy

  
[View profile](https://hashnode.com/@Kupadhy)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
