5 ms·
> The nuisance of having to add self as parameter to every class method This was done intentionnaly, because "Explicit is better than implicit". It also has so
by progval 7y ago
> The nuisance of having to add self as parameter to every class method
This was done intentionnaly, because "Explicit is better than implicit". It also has some uses, eg. if you want to do this:
class Foo:
def inject_bar(self):
def new_bar(self2):
pass # you can refer to both 'self' and 'self2 here
other_object.bar = new_bar
It's rare, but it has its uses.
- tomp 7y ago> "Explicit is better than implicit" Too bad Python breaks this "commandment" pretty much whenever it wants to.
- progval 7y agoYeah, The Zen of Python has commandments to justify pretty much anything. eg. "Simple is better than complex." or "Readability counts." when you want something to be implicit
- rectangletangle 7y ago"Practicality beats purity"