Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Conditional Check

i am not able to grasp the concept of this video, can someone please explain this in simple words??

i have not understood the concept here like what does_name_ and main do???

1 Answer

Steven Parker
Steven Parker
229,921 Points

The "__name__" variable is set for you by the Python system. If the code that checks it is was brought in with an "import" statement, then it will be filled with the name used to import the code.

But if the code that checks it is in the main program, it will contain the string "__main__" instead of a name.