Some observations from a new user, for what they’re worth.
The app callback functions are, how do I put it, snobbish? Specifically, the variable/parameter “input_value” Here’s what I have to start with:
@app.callback(
Output(component_id='my-div', component_property='children'),
[Input(component_id='my-id', component_property='value')]
)
def update_output_div(input_value):
return 'You\'ve entered "{}"'.format(input_value)
Don’t we always expect a variable to be declared somewhere so we always understand context? I mean this broadly, not just in programming. If I wanted you to bring me something from the kitchen table I wouldn’t make up a word and say, bring me the “tokoticoat”. I’d point to the item and say, bring me the “honey”. Or, I might just say “bring me what’s on the table” so you know the item is a dummy variable of the table.
In the above sample code, “input_value” seems to be a real name, like “honey”. But I don’t see it declared anywhere. I feel stupid, what does everyone else know about “input_value”?
Then I noticed that if I put in “tokoticoat” it works the same. Why, because the function under the callback takes whatever was put into the input. It’s a parameter name you call whatever you want. I’m new to this, am I wrong? Philosophically, should anything be named that we have no control over?
A better variable would just be an underscore say, so
@app.callback(
Output(component_id='my-div', component_property='children'),
[Input(component_id='my-id', component_property='value')]
)
def update_output_div(_):
return 'You\'ve entered "{}"'.format(_)
Or maybe “dash_callback_input”
Declarative programming can be very powerful. It can also be inscrutable. I’m finding it very frustrating and feel some of it can be avoided.
Again, just my observations before I learn this stuff and move on. If you want more Dash adoption, I believe you need to be kinder to a new person’s naming expectations. Back to having some fun!