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 Methods

James Ball
James Ball
2,074 Points

Why does kenneth.pickpocket(self) return an error?

I understand why you need to include an instance argument when performing a method on the class e.g. Thief.pickpocket(kenneth).

What I don't understand is why you get an error when you specify the self argument when performing a method on an instance e.g. kenneth.pickpocket(self).

I know that self is not required but why does it not work if specified?

1 Answer

Steven Parker
Steven Parker
230,248 Points

When you call a method on an instance, the system provides the first argument for you, so passing an explicit one is actually going to pass two arguments in to the method.

Another issue in this case is that the term "self" has not been defined in the outer context where you are attempting the call.