sympy象征表达的类型

发布于 2025-02-11 06:36:05 字数 295 浏览 1 评论 0原文

我的函数只能接受类型类型的参数,就像您打电话时一样,

type(type)

type(type(sympy.symbols("a"))

不是type,而是sympy.core.core.assumptions.manavedproperties

我想知道是否有一种方法可以使类型(符号(“ A”))抛出type

I have a function that should only accept arguments of type type, as when you call

type(type)

but the output of

type(type(sympy.symbols("a"))

is not type, but rather sympy.core.assumptions.ManagedProperties.

I wonder if there is a way to make it so that the type(symbols("a")) throws out type.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫罗兰の梦幻 2025-02-18 06:36:05

ManagedProperties类本身是类型的子类:

In [7]: type(type(symbols("a"))).__mro__
Out[7]: 
(sympy.core.assumptions.ManagedProperties,
 sympy.core.core.BasicMeta,
 type,
 object)

从这个意义上说,它已经是type ,或者不必有任何理由来将其与类型

In [8]: isinstance(type(symbols("a")), type)
Out[8]: True

In [9]: issubclass(type(type(symbols("a"))), type)
Out[9]: True

The ManagedProperties class is itself a subclass of type:

In [7]: type(type(symbols("a"))).__mro__
Out[7]: 
(sympy.core.assumptions.ManagedProperties,
 sympy.core.core.BasicMeta,
 type,
 object)

In that sense it is already type or rather there shouldn't need to be any reason to distinguish it from type:

In [8]: isinstance(type(symbols("a")), type)
Out[8]: True

In [9]: issubclass(type(type(symbols("a"))), type)
Out[9]: True
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文