The right way to 'call' a class attribute inside the same class

Erik python at
Thu Dec 15 19:36:46 EST 2016

On 12/12/16 23:23, Chris Angelico wrote:
> In JavaScript, it's normal to talk about "calling a function as a
> constructor". When you do, there is a 'this' object before you start.

No there isn't. There is an implicit binding of a variable called "this" 
based on the syntactic sugar of whether you're calling a function as 
method on an object or not.

In "strict" mode, this has been redefined to be "undefined" (i.e., there 
is no object) for when you're not - otherwise it will be a binding to 
the global "document" object (and in Node.js, I think something else 
entirely. It's a mess ...).

> Ultimately, every language has slightly different semantics

You're not wrong ;)


More information about the Python-list mailing list