Reputation: 303
there are several ways to find the corresponding functions of on Object, the one I have been using often is 'dir':
import matplotlib.pyplot as plt
fig = plt.gcf()
dir(fig)
Now suppose, that I have an idea how the function is called; for example, it’s set_size***
. In this case, though, I am not completely sure if it’s set_size_inches
or set_size_inch
.
Is there any way that I could provide my partial piece of information to figure out the complete correct name of the function?
Something like:
hasattr(fig, set_size*)
Upvotes: 0
Views: 107
Reputation: 36
You could probably use inspect module for it and filter through it but honestly, the best way is probably google or documentation
Upvotes: 0
Reputation: 4707
You can find all module's members like this
[fn for fn in fig if fn.startswith('set_size')]
So you can get module function
fn_name = [fn for fn in fig.__dict__.keys() if fn.startswith('set_size')][0]
fn = getattr(fig, fn_name)
Upvotes: 1