I'm trying to wrap my head around the way positional and keyword arguments work in python, and, it seems, I'm failing rather miserably.
Given a function with a call signature matplotlib.pyplot.plot(*args,**kwargs), it can be called as
import matplotlib.pyplot as plt
x=[1,2,3]
y=[5,6,7]
plt.plot(x,y,'ro-')
plt.show()
Now, I'm trying to wrap it into something which I can call as mplot(x,y,'ro-',...) where ... are whatever arguments the original function was ready to accept. The following fails miserably, but I can't really figure how to fix it:
def mplot(x,y,fmt,*args,**kwargs):
return plt.plot(x,y,fmt,*args,**kwargs)
mplot(x,y,'ro-')
Any pointers to a way out would be very much appreciated.
plotas it is. What's motivating this question?