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 Object-Oriented Python Instant Objects Your first class

Roniel Flores
Roniel Flores
821 Points

I dont know the next step of this ... should I had seen in the video

how do I make an instance of me?

first_class.py
class Student:
    name = "Roniel FLores"
    me = print(Roniel FLores)
Roniel Flores
Roniel Flores
821 Points

I tried it, doesnt work, please help, I am stuck here lol and cant move forward.

thank you,

Roniel

2 Answers

Christian Mangeng
Christian Mangeng
15,970 Points

Hi Roniel,

this is how you create the instance:

me = Student()

It creates an instance of Student that is called "me". Note that the instance needs to be created OUTSIDE the Student class definition (so it's not indented). The instance takes no arguments for its initialization, that's why the parentheses are empty. Now you can access the name property of the Student instance (which is called: me) with me.name

Roniel Flores
Roniel Flores
821 Points

so put a pass and then me = student() ?

Christian Mangeng
Christian Mangeng
15,970 Points

A class is not a function, so it does not require a pass. It is complete like this:

class Student:
    name = "Roniel FLores"

Now you can create the instance (below the class, but not inside of it) and then print me.name. This prints what is stored in the name variable of the class.

Roniel Flores
Roniel Flores
821 Points

it does not work, I try multiple ways