@bestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish • 2 days agoThe meaning of thislemmy.mlimagemessage-square62arrow-up1511
arrow-up1511imageThe meaning of thislemmy.ml@bestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish • 2 days agomessage-square62
minus-square@WolfLink@sh.itjust.workslinkfedilink39•1 day agoIn 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.
minus-square@jsomae@lemmy.mllinkfedilink4•1 day agoLua might have been a better choice, since self is special in lua.
minus-squareDie Martin Dielinkfedilink1•21 hours agoKinda. Lua defines it implicitly only when you use the function foo:bar(a, b, c) -- note the colon syntactic sugar, which gets translated to 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.
minus-square@jsomae@lemmy.mllinkfedilink1•19 hours agoI 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.
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.
Lua might have been a better choice, since
self
is special in lua.Kinda.
Lua defines it implicitly only when you use the
function foo:bar(a, b, c) -- note the colon
syntactic sugar, which gets translated to
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.
Python is just distancing itself from JS.