@[email protected] to Programmer [email protected]English • 11 days agoThe meaning of thislemmy.worldimagemessage-square71fedilinkarrow-up1475cross-posted to: [email protected]
arrow-up1475imageThe meaning of thislemmy.world@[email protected] to Programmer [email protected]English • 11 days agomessage-square71fedilinkcross-posted to: [email protected]
minus-square@[email protected]linkfedilink45•11 days 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@[email protected]linkfedilink7•11 days agoLua might have been a better choice, since self is special in lua.
minus-squareDie Martin Dielinkfedilink6•edit-29 days 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 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. Edit: some typos
minus-square@[email protected]linkfedilink3•11 days 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.
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
syntactic sugar, which gets translated to
In all 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.Edit: some typos
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.
Derp, I misread.