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 trialPitrov Secondary
5,121 Points05:02 Why does he do dice.D6() and not only D6() or Die.D6?
at 05:02 he writes d6 = dice.D6() Why does he need to add dice before the D6?
1 Answer
Steven Parker
231,269 PointsThe "import dice
" statement gives access to the classes in the file "dice.py" file, but you still need to prefix them with the file name, like "dice.D6()
".
But you could import the class directly instead, like this: "from dice import D6
". Then you could just refer to "D6()
" as if it was defined in the same file.