Python中具有多个可选预定义参数的方法

发布于 2025-02-09 08:32:39 字数 323 浏览 1 评论 0原文

我总是找到具有多个预定义参数的方法非常友好,例如:

plt.plot([1,2,3], [5,1,2], color = "black", linewidth=10)

在此示例中参数是未定义的(** kwargs)。 如图所示的参数的建议伴随着使用的简单性: 建议的参数 我试图探索方法.plot(),它使我进入了一个深兔子孔。问题是,您将如何实施这种行为?

I always find very user-friendly the methods with multiple predefined parameters such as:

plt.plot([1,2,3], [5,1,2], color = "black", linewidth=10)

In this example the order of the arguments color and linewidth is indifferent, in addition the type of the arguments is undefined (**kwargs).
The easiness of use comes with the suggestion of parameters as shown in the picture:
Suggested parameters
I tried to explore the method .plot() and it lead me into a deep rabbit hole. The question is, how would you implement such a behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文