I have a Python class with a method which should accept arguments and keyword arguments this way
class plot:
def __init__(self, x, y):
self.x = x
Here's a slight tweek to Jure C.'s answer:
def set_axis(self, *args, **kwargs):
xlabel = kwargs.pop('xlabel', 'x')
ylabel = kwargs.pop('ylabel', 'y')
I changed get
to pop
to remove xlabel
and ylabel
from kwargs
if present. I did this because the rest of the code in the original question contains a loop that is meant to iterate through all kwargs
except for xlabel
and ylabel
.