Python try_decorator to retry i2c connections

I am communicating with some hardware over an I2C bus. Every so often, there is an exception as the bus is busy so I am currently handling this with a loop that retries, but there’s a lot of code repetition, I want to tidy it up. So, I tried to write a decorator function to pass various functions to As an example, this command initialises the bus: i2c = busio.I2C(board.SCL, board.SDA) This is the decorator I have written: And then I try to pass it the line mentioned above as a partial: i2c = try_decorator(partial(busio.I2C, board.SCL, board.SDA), ‘i2c init’) but

Python Decorator, Wrapper got argument multiple times

I wrote this decorator to be used by two functions: I keep getting the error: How can I pass the argument page recursively without having it multiple times? Thanks! EDIT: functions are called as in: Answer Positional arguments in python must be passed in order of definition in the function prototype. This line passes the value of survey_id to the argument page as it’s the second argument passed. Call the function as: