當前位置: 首頁>>代碼示例>>Python>>正文


Python SomeObject.is_type_of方法代碼示例

本文整理匯總了Python中pypy.annotation.model.SomeObject.is_type_of方法的典型用法代碼示例。如果您正苦於以下問題:Python SomeObject.is_type_of方法的具體用法?Python SomeObject.is_type_of怎麽用?Python SomeObject.is_type_of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pypy.annotation.model.SomeObject的用法示例。


在下文中一共展示了SomeObject.is_type_of方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: union

# 需要導入模塊: from pypy.annotation.model import SomeObject [as 別名]
# 或者: from pypy.annotation.model.SomeObject import is_type_of [as 別名]
 def union((obj1, obj2)):
     if obj1 == obj2:
         return obj1
     else:
         result = SomeObject()
         if obj1.knowntype == obj2.knowntype and obj1.knowntype != object:
             result.knowntype = obj1.knowntype
         is_type_of1 = getattr(obj1, 'is_type_of', None)
         is_type_of2 = getattr(obj2, 'is_type_of', None)
         if obj1.is_immutable_constant() and obj2.is_immutable_constant() and obj1.const == obj2.const:
             result.const = obj1.const
             is_type_of = {}
             if is_type_of1:
                 for v in is_type_of1:
                     is_type_of[v] = True
             if is_type_of2:
                 for v in is_type_of2:
                     is_type_of[v] = True
             if is_type_of:
                 result.is_type_of = is_type_of.keys()
         else:
             if is_type_of1 and is_type_of1 == is_type_of2:
                 result.is_type_of = is_type_of1
         # try to preserve the origin of SomeObjects
         if obj1 == result:
             result = obj1
         elif obj2 == result:
             result = obj2
         unioncheck(result)
         return result
開發者ID:alkorzt,項目名稱:pypy,代碼行數:32,代碼來源:binaryop.py


注:本文中的pypy.annotation.model.SomeObject.is_type_of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。