3 ms·
As a former Python dev, default arguments are nice but they get abused to hell. Need to add functionality to something? Don't think! Just add an argument with
by skrtskrt 4y ago
As a former Python dev, default arguments are nice but they get abused to hell.
Need to add functionality to something? Don't think! Just add an argument with a default to the current behavior, all the way up and down the stack.
Now you have just one API that does everything! Just set 20-40 parameters to decide the behavior.
- codedokode 4y agoPython just gives you a choice, use named arguments or refactor your API and use objects for options. It is up to you how you are going to use it. What I don't like though is when all those options are hidden behind two-stars keyword argument and it is difficult to understand what options are allowed, what they mean, what type they have and so on: def example(**options): ...