set_if_exists
Given a dict d sets the key k with value of config v, if the config value v is set and return the updated dictionary.
def set_if_exists(
d: dict,
k: str,
val: typing.Any
) - > dict
Given a dict d sets the key k with value of config v, if the config value v is set and return the updated dictionary.
Parameters
| Name | Type | Description |
|---|---|---|
| d | dict | The dictionary to which the key-value pair might be added. |
| k | str | The key to set in the dictionary d. |
| val | typing.Any | The value to associate with the key k if it exists. A value is considered to exist if it is a boolean or evaluates to true when converted to a boolean (e.g., not None, not an empty string, not 0). |
Returns
| Type | Description |
|---|---|
dict | The dictionary d after potentially setting the key k with val. |