元组未定义,但包含信息
A tuple is not defined, but it contains information
我正在寻找一个模块 ifcopenshell,我看到了一个非常奇怪的函数:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import functools
import numbers
import itertools
from . import ifcopenshell_wrapper
try:
import logging
except ImportError as e:
logging = type('logger', (object,), {'exception': staticmethod(lambda s: print(s))})
class entity_instance(object):
def __init__(self, e):
if isinstance(e, tuple):
e = ifcopenshell_wrapper.new_IfcBaseClass(*e)
super(entity_instance, self).__setattr__('wrapped_data', e)
在这种情况下,tuple
没有在任何地方明确定义,但它包含一个值。我的假设是 tuple
来自进口。那正确吗?我如何追踪 tuple
来自哪里?
这里是函数 isininstance 的注释:
定义:isinstance(o: object, t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]], /) -> bool
Return 对象是否是 class 或其子class 的实例。
一个元组,如 isinstance(x, (A, B, ...)),可以作为要检查的目标。这相当于 isinstance(x, A) 或 isinstance(x, B) 或 ... 等等
我正在寻找一个模块 ifcopenshell,我看到了一个非常奇怪的函数:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import functools
import numbers
import itertools
from . import ifcopenshell_wrapper
try:
import logging
except ImportError as e:
logging = type('logger', (object,), {'exception': staticmethod(lambda s: print(s))})
class entity_instance(object):
def __init__(self, e):
if isinstance(e, tuple):
e = ifcopenshell_wrapper.new_IfcBaseClass(*e)
super(entity_instance, self).__setattr__('wrapped_data', e)
在这种情况下,tuple
没有在任何地方明确定义,但它包含一个值。我的假设是 tuple
来自进口。那正确吗?我如何追踪 tuple
来自哪里?
这里是函数 isininstance 的注释:
定义:isinstance(o: object, t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]], /) -> bool Return 对象是否是 class 或其子class 的实例。 一个元组,如 isinstance(x, (A, B, ...)),可以作为要检查的目标。这相当于 isinstance(x, A) 或 isinstance(x, B) 或 ... 等等