Di sini
adalah bagian dari kode yang menangani tipe kompleks di cx_Oracle.
Kutipan:
def ObjectRepr(obj):
if obj.type.iscollection:
returnValue = []
for value in obj.aslist():
if isinstance(value, cx_Oracle.Object):
value = ObjectRepr(value)
returnValue.append(value)
else:
returnValue = {}
for attr in obj.type.attributes:
value = getattr(obj, attr.name)
if value is None:
continue
elif isinstance(value, cx_Oracle.Object):
value = ObjectRepr(value)
returnValue[attr.name] = value
return returnValue
Anda menggunakannya seperti ObjectRepr(complex[0][0])
, jika len(complex)>0
, tentu saja