0

We have quite a big code base containing lots of functions in python.

Due to recent changes, we need to add a kwarg to every function.

We of course can manually change all the functions' signature to have the kwarg, but is there a better way to do it?

Maybe in interpreter level? Before every function is called, add that kwarg into it?

Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
  • Ugh, i don't think it is possible. – U13-Forward Jan 15 '19 at 09:31
  • If you end up changing your code (i guess you have to), you might want to include **kwargs into every functions signature (and pass those through) to prevent yourselfes from having to change all the signatures again next time you find out that you are missing some arguments in a low level function... – Schorsch Jan 15 '19 at 09:35
  • What is the point of adding a kwarg to a function if its not used? You gotta change the body of the function as well – dopstar Jan 15 '19 at 09:35
  • 1
    While Python is dynamic enough to allow that with some tricks, it would violate some of the core principles for Python code like readability. Imagine a new developer looking into the code where arguments have been added dynamically from somewhere else. – Klaus D. Jan 15 '19 at 09:41

0 Answers0