1

What's the best way to understand which **kwargs are valid for a given python function?

I often need to use python functions that can accept additional keyword arguments as **kwargs, but I am unsure which **kwargs I can use.

For example, I am currently looking at the matplotlib.pyplot.subplot2grid function docs https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.subplot2grid.html but it doesn't give any further information.

feedMe
  • 3,431
  • 2
  • 36
  • 61
  • It says: `**kwargs: Additional keyword arguments are handed to add_subplot.` So you would have to check the documentation of `add_subplot`. – mkrieger1 Oct 02 '20 at 09:11
  • According to the documentation, "Additional keyword arguments are handed to add_subplot.". – juanpa.arrivillaga Oct 02 '20 at 09:11
  • it's just a way to explode a dictionary https://stackoverflow.com/questions/63223650/how-to-merge-dict-of-dict-in-python/63223847#63223847 – Weilory Oct 02 '20 at 09:14

1 Answers1

2

It really depends on the specifics of the function, if it's not documented there's not much you can do short of diving through the code.

Here, the documentation does tell you:

Additional keyword arguments are handed to add_subplot.

So you can look at the documentation for add_subplot and see what kwargs are likely acceptable.

Masklinn
  • 34,759
  • 3
  • 38
  • 57