Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

boi
boi
8,827 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.