本文整理匯總了Python中pypy.annotation.model.SomeObject.getattr方法的典型用法代碼示例。如果您正苦於以下問題:Python SomeObject.getattr方法的具體用法?Python SomeObject.getattr怎麽用?Python SomeObject.getattr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pypy.annotation.model.SomeObject
的用法示例。
在下文中一共展示了SomeObject.getattr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getattr
# 需要導入模塊: from pypy.annotation.model import SomeObject [as 別名]
# 或者: from pypy.annotation.model.SomeObject import getattr [as 別名]
def getattr(p, s_attr):
if s_attr.is_constant() and isinstance(s_attr.const, str):
# XXX kill with extfunctable.py
if p.knowntype in builtin.EXTERNAL_TYPE_ANALYZERS:
return SomeObject.getattr(p, s_attr)
attr = s_attr.const
entry = extregistry.lookup_type(p.knowntype)
s_value = entry.get_field_annotation(p.knowntype, attr)
return s_value
else:
return SomeObject()
示例2: getattr
# 需要導入模塊: from pypy.annotation.model import SomeObject [as 別名]
# 或者: from pypy.annotation.model.SomeObject import getattr [as 別名]
def getattr(s_array, s_attr):
s = None
if s_attr.is_constant() and isinstance(s_attr.const, str):
attr = s_attr.const
if attr == 'shape':
s = SomeTuple([SomeInteger()]*s_array.ndim)
elif attr == 'ndim':
s = SomeInteger()
elif attr == 'dtype':
s = SomeChar()
if s is None:
return SomeObject.getattr(s_array, s_attr)
return s