The meaning of this
The meaning of this
The meaning of this
You're viewing a single thread.
In Python, self is not a keyword, it’s a conventional variable name. You can replace all instances of “self” with “this” and your code will work the same.
Python is just distancing itself from JS.
Lua might have been a better choice, since self
is special in lua.
Kinda.
Lua defines it implicitly only when you use the
lua
function foo:bar(a, b, c) -- note the colon
syntactic sugar, which gets translated to
lua
function foo.bar(self, a, b, c)` -- note the period
In all other cases, self
is a regular variable name. You can even redeclare a new local with that name even when the old one is in scope.
I don't see how what you said is inconsistent with me saying "self" is special in lua. Note that I did not say it's a keyword.