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

Cannot create instance of a class without console. No console is given.

I'm trying to complete the first exercise. It requires I create an instance of the Student class called me.

I've only been taught how to do this using console, but nothing is visible. Could this be a bug?

first_class.py
class Student:
    name = 'Jacob'

me = Student()

me.name

1 Answer

Ryan S
Ryan S
27,275 Points

Hi Jacob,

No its not a bug, you can instantiate an object inside a file just like you would call a function after defining it. But you are probably correct to perceive it as bit strange because often you would define your classes in their own .py file, and instantiate them in another, or in the terminal, or as a model instance in a database.

But you pretty much solved this challenge, the only thing is that you forgot to print the last line.