0

UPDATE: I learned the basics of matplotlib so now I realize my previous question was out of place, but now I've run into a new problem. Let's say I have a slider that is updated with

def update_execution(val):
    executionStep = int(executionSlider.val)
    #Do stuff

slider.on_changed(update_execution)

Is there a way I can modify this so that I can pass other arguments to update_execution()? i.e something like this:

def update_execution(val, globalparam):
    executionStep = int(executionSlider.val)
    globalparam = 'foo'
    #Do stuff

slider.on_changed(update_execution(globalparam))`

Thanks :)

Meme Overlord
  • 997
  • 1
  • 9
  • 16

1 Answers1

0

Definitely not a best practice, although in small contexts it doesn't really matter, but I figured out the best way to solve this is is by declaring the variable you want to modify as a global var

def update_execution(val):
    executionStep = int(executionSlider.val)
    global globalparam
    globalparam = 'foo'
    #Do stuff 
slider.on_changed(update_execution)
Meme Overlord
  • 997
  • 1
  • 9
  • 16