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 trialBenyamin Kohanchi
Courses Plus Student 2,342 PointsWhy would we use dunder main? Just don't import the file? I'm confused.
Kind of confused, if we don't want a certain file to be run, then don't import it in the first place.
What am I missing here? 😅
2 Answers
Nikolai Olekhnovitch
Front End Web Development Techdegree Graduate 25,617 PointsHello! You will eventually build more complex programs that require you to import different scripts you wrote. Using main enables to have control over how everything is run and is a good practice for others to understand your code. Hope this helps!
Abdulsalam Jumah
3,679 Pointswhen expand the level of your project this will become much more obvious and very helpful this actually important in the important in the functionality and popularity just look at already available python libraries that you can import such as math which was shown in the first course and such as numpy and pandas which is why python is so popular in the datascience field.
Benyamin Kohanchi
Courses Plus Student 2,342 PointsBenyamin Kohanchi
Courses Plus Student 2,342 PointsGreat thanks!