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

boi
boi
14,241 Points

Object-oriented Python, Dice roller, Giving a Hand (MRO). Need help understanding teacher's notes.

In the videos' teacher's notes, Kenneth explains the use of the die_count() argument, after that, there is an example that explains it more.

I did understand that we can use Classes as an argument, however, I did NOT understand the example that was showed there. Like what is the purpose of the function:

def vehicle_factory(cls, count):
    for _ in range(count):
        yield cls()

The document said that this function is used to create as many instances as we want, but I don't totally understand what that means.

Here is the link to that video.