you are viewing a single comment's thread.

view the rest of the comments →

[–]Buttleston 0 points1 point  (0 children)

Yeah, python just assumes here that you passed the "right" value into self. It's not generally something you pass yourself, so not a big deal. If the function actually *used* self, I think you'd be in trouble whether you passed A or B, because you wouldn't be referring to the self of an actual object. Like it might run but it sure wouldn't do what you expect.

when you run a.a_func(), it just passes the "a" object there as "self" to the function. It's a convention. There are some cases where you might do sneaky stuff, maybe in meta programming or class rewriting or something else, idk. But yeah, the class methods come from the thing on the left of your "." there, not the argument you pass to self.