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 trialKafe Hezam
11,070 PointsWhen Kenneth calls the instance five it returns back the object, why is that?
When Kenneth calls the instance five it returns back the object, why is that? Wouldn't it return back 5 since the magic str method calls it automatically?
1 Answer
lemelleio
10,874 PointsWhen Kenneth called the object 'Five' he got back a representation of the object, which by default is its location in memory. This is dictated by the dunder method Repr.
If he had overridden Repr he could have it return the str representation of it upon being called.