3 ms·
The python way of doing ‘classes’ is pretty hideous to me. Why a self argument on every function?
by Aeolun 6y ago
The python way of doing ‘classes’ is pretty hideous to me. Why a self argument on every function?
- dragonwriter 6y ago> Why a self argument on every function? A self argument is on methods because then, from the inside, methods are identical to functions, rather than functions with additional implicit magic. Also because it's a function member of the class with exactly that argument pattern; calling instance.method(...) is just syntax sugar for ClassOfInstance.method(instance, ...). This also makes Python handling of unbound methods a lot cleaner than, say, Ruby.