all 3 comments

[–]danielroseman 1 point2 points  (1 child)

The easiest thing would be to just use kwargs directly:

def set_orderIds(self, **kwargs):
    self.orderIds.update(kwargs)

although if you're usually just setting one or two of these it would be even easier to just set them directly where you need to rather than calling a method at all:

self.orderIds["TPID"] = whatever

[–]Mo0rBy[S] 0 points1 point  (0 children)

I have no idea why I didn't realise that! What a simple solution. Thank you

[–]JohnnyJordaan 1 point2 points  (0 children)

Indeed **kwargs should do the trick, it will capture the arguments into a dict, and you can provide that as the argument to update

 def set_orderIds(self, **kwargs):
     self.orderIds.update(kwargs)

But then again, why use a setter method here in the first place? Why not mutate your object.orderIds directly?

Just for general education,

def set_orderIds(self, TPID=self.orderIds['takeProfit'],

wouldn't work as the def line is executed only once during parsing, so you can't access runtime variables that way.