View source on GitHub |
Construct a dictionary containing attributes from obj
cirq.obj_to_dict_helper(
obj: Any, attribute_names: Iterable[str]
) -> Dict[str, Any]
This is useful as a helper function in objects implementing the
SupportsJSON protocol, particularly in the _json_dict_
method.
In addition to keys and values specified by attribute_names
, the
returned dictionary has an additional key "cirq_type" whose value
is the string name of the type of obj
.
Args | |
---|---|
obj
|
A python object with attributes to be placed in the dictionary. |
attribute_names
|
The names of attributes to serve as keys in the resultant dictionary. The values will be the attribute values. |