Why take quarts but not use them?

I looked at the source code of Django today, and I noticed this:

class DjangoTestSuiteRunner(object): def __init__(self, verbosity=1, interactive=True, failfast=True, **kwargs): self.verbosity = verbosity self.interactive = interactive self.failfast = failfast 

Why should they accept kwargs in the constructor, but then do nothing with them?

+4
source share
1 answer

This pattern can simplify backward / forward compatibility. If a newer / older version of the code has more / less parameters, you will not break everything.

Also, when you inherit this class (e.g. with mixins), it may be convenient to just accept everything.

IMHO this is not a pretty template to use, but it works.

+9
source

Source: https://habr.com/ru/post/1414482/


All Articles