class_docstr: Provides an easy-to-use python object for abstracting Thrift "unions",
  allowing a python obj to be automatically mapped to the correct union
  field.
class_docstr_tok: ["Provides","an","easy-to-use","python","object","for","abstracting","Thrift","``","unions","''",",","allowing","a","python","obj","to","be","automatically","mapped","to","the","correct","union","field","."]
docstr: Get the python object set in the union.
docstr_tok: ["Get","the","python","object","set","in","the","union","."]
code: def get_py_obj(self):
      """
      Get the python object set in the union.
      """
      attrs = [
          a
          for a in dir(self.union)
          if not (a.startswith("_")) and a not in self.non_attrs
      ]
      # Much like a C union, only one field will be set. Return the first
      # non-None value encountered.
      for a in attrs:
          val = getattr(self.union, a)
          if val is not None:
              # Assume all lists are homogeneous. Check the first item to see
              # if it is a Value or ValueWrapper obj, and if so recurse.
              # FIXME: this might be slow, consider handling lists of numbers
              # differently
              if isinstance(val, list) and len(val) > 0:
                  if isinstance(val[0], Value):
                      return [ValueWrapper(i).get_py_obj() for i in val]
                  elif isinstance(val[0], ValueWrapper):
                      return [i.get_py_obj() for i in val]
                  else:
                      raise TypeError(
                          f"expected Value or ValueWrapper, got {type(val)}"
                      )
              else:
                  return val
  
      return None
  
file_path: cugraph/python/cugraph-service/client/cugraph_service_client/types.py
imports: from cugraph_service_client.cugraph_service_thrift import spec
label_desc: Use image node_id 3 for calling the ValueWrapper obj's underlying member method code with example usage: obj.get_py_obj() and returns: None, val, unknown, unknown