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

Items.py

when did the instructor create the items.py file?

Could you please tell us what video this is for?

1 Answer

Hi Matthew Earlywine!

Are you referring to the Items.py in the OOP Emulating Built-ins video? If you are: Kenneth doesn't show himself making that file. I paused the video and typed out the code so you can just copy it and paste it into your own items.py file if you like.

class Item:
    def __init__(self, name, description):
        self.name = name
        self.description = description

    def __str__(self):
        return '{}: {}'.format(self.name, self.description)


class Weapon(Item):
    def __init__(self, name, description, power):
        super().__init__(name, description)
        self.power = power

Best,

Nakal

Sorry, I meant to update this question. It is from the Emulating Built-ins video. I fond the file that contains all the codes. In the downloads tab on the video. I was able to retrieve the code from there.

Great! :)