Skip to content

utils.py

a script of utility functions that are useful for webcode-tk but don't belong to any one particular webcode tool.

get_first_dict_key(some_dict)

returns the first key of a dictionary.

Parameters:

Name Type Description Default
some_dict dict

a dictionary (any dictionary)

required

Returns:

Name Type Description
first_key str

the first key of a dictionary

Source code in webcode_tk/utils.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def get_first_dict_key(some_dict: dict) -> str:
    """returns the first key of a dictionary.

    Args:
        some_dict: a dictionary (any dictionary)

    Returns:
        first_key: the first key of a dictionary"""
    first_key = some_dict.keys()
    first_key = list(first_key)
    first_key = first_key[0]
    return first_key