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 trialDominika Petriková
11,779 Points__name__ == '__main__'
Hi, is it necessary to use name == 'main' here? I understand why we used it in the file cards.py but we're not going to import game.py anywhere, are we? Thanks
1 Answer
Megan Amendola
Treehouse TeacherAt the moment, no, but it is a good habit to get into. When projects get bigger, it can be easy to forget to go back and place things inside of a dunder main statement.
For instance, you could create a variety of games and then import them all into a file where a user gets to choose which game they want to play. You would want the dunder main statement then so your console has only the messages you want.
Dominika Petriková
11,779 PointsDominika Petriková
11,779 PointsThat makes sense. Thank you :)