Message to Self. What’s this?
Where C++ has this
, Python has self
.
Unlike C++’s this
you’re not required to refer to the current
object as self
: you could call it me
, or current_object
, or
even this
— but you’d have to be feeling pretty perverse to adopt
such a non-idiomatic style. And also unlike C++, you do have to explicitly
name the current object, which some find tiresome.
Python does have a standard this
library, though. It isn’t
documented. It isn’t even tested. To see what it does, open a command
shell and type:
python -c "import this"
Go on, try it!