Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Dash overwriting self in class methods

Hi all,

We’re trying to port an app onto Dash but are having a bit of trouble. One issue I haven’t found a workaround for is using dash within class definitions ----
class Example:
def init(self):

@app.callback(Output('comp-id', 'value'), [Input('interval-id2', 'n_intervals)])
def foo(self):

I get an error that ‘int’ self has no attribute ‘bar()’. Is there a way to support self in callback definitions or have dash ignore it?? or better yet, mix dash params with ordinary params?

The self parameter will not be self when called by dash, it will be the n_interval. If you need a ref to self when registering callbacks, you can register the callbacks in a factory method.


def register_callbacks(self, app):
    def foo(n_interval):