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

Why isn't the self parameter called when using the new method

Why isn't the self parameter called when using the new method

1 Answer

Hiya there! In order to understand how an object is instantiated , you're gonna to learn how Python self actually works. If you're coming to Python from other languages like Ruby or JavaScript, they have something similar to keyword self. JavaScript has this and Ruby has self which works pretty similar to this in python.

Alright so self references to the owner of the method on which its called. Consider it a placeholder for future object or class its going to replace. So yeah when we instantiate some class, that object is going to replace self. Now since Python follows explicit is better than implicit, thats why you're gonna have to be explicit about it. But in the other languages, it happens behind the scene.

Just remember this, the object that will be created on the same class will replace self in the future. self holds the references to the object that will be created on the class.

~ Ari