python - "suppress_callback_exceptions"在破折号 Python 中的作用是什么?

标签 python python-3.x dashboard plotly-dash multipage

这样写有什么区别:

app = dash.Dash(__name__, suppress_callback_exceptions=True,
                meta_tags=[{'name': 'viewport',
                            'content': 'width=device-width, initial-scale=1.0'}]
                )
server = app.server

还有这个:

app = dash.Dash(__name__, suppress_callback_exceptions=False,
                meta_tags=[{'name': 'viewport',
                            'content': 'width=device-width, initial-scale=1.0'}]
                )
server = app.server

最佳答案

来自source code :

suppress_callback_exceptions: check callbacks to ensure referenced IDs exist and props are valid. Set to True if your layout is dynamic, to bypass these checks.

因此,您自己链接的示例并没有真正的区别。或者更确切地说,如果 app 具有引用不存在的 id 和/或无效 Prop 的回调,或者如果 app.layout 中的元素具有无效 Prop ,您只会遇到不同的行为。

suppress_callback_exceptions 设置为 True 的原因可能是因为您有通过 id 引用元素的回调,但这些元素在生命周期中并不总是出现在布局中的应用程序。例如,元素可能会通过不同的回调动态插入到 app.layout 中。

documentation 中的另一个示例

...Since suppress_callback_exceptions=True is specified here, Dash has to assume that the input is present in the app layout when the app is initialized...

关于python - "suppress_callback_exceptions"在破折号 Python 中的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67546867/

相关文章:

Python 正则表达式捕获由空格和逗号分隔的数字和破折号

python - statsmodels:使用 patsy 指定非线性回归模型

python - 使用 opencv python 绑定(bind)将帧从网络摄像头保存到磁盘

database - 如何在 Redash 中配置 Apache Ignite

javascript - 获取Category过滤控件的类型

python - 多个 python 装饰器检索原始函数

python - 导入错误 : cannot import name Thread

python - 如何对二进制字符串列表进行排序

session - 更新了 Pyramid 模型目录结构,现在 session 已损坏

elasticsearch - Kibana仪表板中的用户级别访问控制