4 ms·
I like the self parameter, because it makes the language more powerful. You can now simply assign a function to a class and make it a member method if it accept
by panzi 12y ago
I like the self parameter, because it makes the language more powerful. You can now simply assign a function to a class and make it a member method if it accepts an appropriate first parameter. The opposite is equally true. You can do something like `map(Class.method, sequence)`.
- agumonkey 12y agoIn javascript you can rebind functions to any context without explicit self in signature. I admit this (PNI) was deeply confusing at first but I tend to prefer this way now. It feels a simpler and more general abstraction.
- panzi 12y agoBut then getting a reference to a bound method is simpler in Python: bound_method = object.method In JavaScript one would have to write: var bound_method = object.method.bind(object);
- panzi 12y agoAlso for unbound methods to make them usable as functions. Python: func = Foo.method JavaScript: var func = Function.prototype.call.bind(Foo.prototype.method);