I'm working on pulling some functionality out of one object and putting it in another, and I came across this interesting problem:
What does this print?
And, next question, why is that?
After lunch I'll post my thoughts
Until now, I had assumed that the semi-magic
self variable was set on method calls (ie, when
x.get_me() is called)... But apparently it's set when the object is instantiated (which makes perfect sense, otherwise
getattr(Bar(), 'get_me')() would not work).
So I can only presume that something equivalent to this happens when an object is instantiated: