Variant

Added in version 2.24.

class Variant(*args, **kwargs)
Constructors:

new_array(child_type:GLib.VariantType=None, children:list=None) -> GLib.Variant
new_boolean(value:bool) -> GLib.Variant
new_byte(value:int) -> GLib.Variant
new_bytestring(string:list) -> GLib.Variant
new_bytestring_array(strv:list) -> GLib.Variant
new_dict_entry(key:GLib.Variant, value:GLib.Variant) -> GLib.Variant
new_double(value:float) -> GLib.Variant
new_fixed_array(element_type:GLib.VariantType, elements=None, n_elements:int, element_size:int) -> GLib.Variant
new_from_bytes(type:GLib.VariantType, bytes:GLib.Bytes, trusted:bool) -> GLib.Variant
new_from_data(type:GLib.VariantType, data:list, trusted:bool, notify:GLib.DestroyNotify, user_data=None) -> GLib.Variant
new_handle(value:int) -> GLib.Variant
new_int16(value:int) -> GLib.Variant
new_int32(value:int) -> GLib.Variant
new_int64(value:int) -> GLib.Variant
new_maybe(child_type:GLib.VariantType=None, child:GLib.Variant=None) -> GLib.Variant
new_object_path(object_path:str) -> GLib.Variant
new_objv(strv:list) -> GLib.Variant
new_signature(signature:str) -> GLib.Variant
new_string(string:str) -> GLib.Variant
new_strv(strv:list) -> GLib.Variant
new_tuple(children:list) -> GLib.Variant
new_uint16(value:int) -> GLib.Variant
new_uint32(value:int) -> GLib.Variant
new_uint64(value:int) -> GLib.Variant
new_variant(value:GLib.Variant) -> GLib.Variant

Methods

class Variant
get_string()

Returns the string value of a Variant instance with a string type. This includes the types %G_VARIANT_TYPE_STRING, %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.

The string will always be UTF-8 encoded, will never be None, and will never contain nul bytes.

If length is non-None then the length of the string (in bytes) is returned there. For trusted values, this information is already known. Untrusted values will be validated and, if valid, a strlen() will be performed. If invalid, a default value will be returned — for %G_VARIANT_TYPE_OBJECT_PATH, this is "/", and for other types it is the empty string.

It is an error to call this function with a value of any type other than those three.

The return value remains valid as long as value exists.

Added in version 2.24.

keys()
classmethod new_tuple()
classmethod split_signature(signature)

Return a list of the element signatures of the topmost signature tuple.

If the signature is not a tuple, it returns one element with the entire signature. If the signature is an empty tuple, the result is [].

This is useful for e. g. iterating over method parameters which are passed as a single Variant.

Parameters:

signature

unpack()

Decompose a GVariant into a native Python object.