• @WolfLink@sh.itjust.works
    link
    fedilink
    455 days ago

    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.

      • Die Martin Die
        link
        fedilink
        6
        edit-2
        3 days ago

        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 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