Skip to content

Dictionary

Contains blocks to work with dictionaries.

clear(*, dictionary)

Clears the dictionary.

Parameters:

Name Type Description Default
dictionary Union[Dict[str, Any], pyconduit.step.ConduitVariable]

The dictionary that will be used in the operation.

required

count(*, dictionary)

Counts the dictionary keys.

Parameters:

Name Type Description Default
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

create(**kwargs)

Creates a new dictionary from keyword arguments.

Parameters:

Name Type Description Default
kwargs

Dictionary.

{}

create_from_list(*, pairs)

Creates a new dictionary with list of pairs.

Parameters:

Name Type Description Default
pairs Union[Tuple[str, Any], List[Tuple[str, Any]]]

A list that contains two values, first is for key and second is for value. You can also provide a list of lists for creating dictionary with more than one pair.

required

create_from_pairs(*, key, value)

Creates a new dictionary with one pairs from "key" and "value" parameters.

Parameters:

Name Type Description Default
key str

Key of the pair.

required
value Any

Value of the pair.

required

delete(*, key, dictionary, silent=True)

Deletes a value and key from dictionary by using key or slice object. If value couldn't found and silent parameter has set to False, it will raise an error. Setting the key to None will delete all keys.

Parameters:

Name Type Description Default
key Union[str, NoneType, slice]

It can be a dictionary key, slice object and None.

required
dictionary Union[Dict[str, Any], pyconduit.step.ConduitVariable]

The dictionary that will be used in the operation.

required
silent bool

Setting it to False will raise an error when value couldn't found.

True

get(*, key, dictionary, default=Empty)

Gets a value from dictionary by using key. If value couldn't found and default parameter has specified, returns the default value. Otherwise, raises an error.

Parameters:

Name Type Description Default
key str

The key that used when getting value from dictionary.

required
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required
default Any

The default value if key is not found in the dictionary.

Empty

is_dictionary(*, value)

Tests to see whether the thing given to it is a dictionary or not.

Parameters:

Name Type Description Default
value Any

Any value.

required

is_key_exists(*, key, dictionary)

Tests whether the key exists in the dictionary.

Parameters:

Name Type Description Default
key str

The key that used when getting value from dictionary.

required
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

is_value_exists(*, value, dictionary)

Tests whether the value exists in the dictionary.

Parameters:

Name Type Description Default
value Any

Any value.

required
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

list_items(*, dictionary)

Returns a list of pairs (as key and value list) in the dictionary.

Parameters:

Name Type Description Default
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

list_keys(*, dictionary)

Returns a list of keys in the dictionary.

Parameters:

Name Type Description Default
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

list_values(*, dictionary)

Returns a list of values in the dictionary.

Parameters:

Name Type Description Default
dictionary Dict[str, Any]

The dictionary that will be used in the operation.

required

merge(*, dict1, dict2)

Merges two dictionaries and returns a new dictionary. If same keys has provided in both dictionaries, dict2 will be dominant.

Parameters:

Name Type Description Default
dict1 Dict[str, Any]

First dictionary.

required
dict2 Dict[str, Any]

Second dictionary.

required

pop(*, key, dictionary, default=Empty)

If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, an error is raised.

Parameters:

Name Type Description Default
key str

The key that used when getting value from dictionary.

required
dictionary Union[Dict[str, Any], pyconduit.step.ConduitVariable]

The dictionary that will be used in the operation.

required
default Any

The default value if key is not found in the dictionary.

Empty

set_(*, key, value, dictionary)

Sets a key and value to dictionary. The key doesn't have to exists in the dictionary.

Parameters:

Name Type Description Default
key str

The key that used when getting value from dictionary.

required
value Any

The value that will be added to dictionary.

required
dictionary Union[Dict[str, Any], pyconduit.step.ConduitVariable]

The dictionary that will be used in the operation.

required

update(*, dict1, dict2)

Updates dict1 by adding values from dict2. It doesn't returns the updated dictionary, instead it updates in place.

Parameters:

Name Type Description Default
dict1 Union[Dict[str, Any], pyconduit.step.ConduitVariable]

First dictionary.

required
dict2 Union[Dict[str, Any], pyconduit.step.ConduitVariable]

Second dictionary.

required