← Reference

Dictionary Methods

Methods available on Python dict objects.

dict.clear()

Removes all items from a dictionary, making it empty

dict.clear()

dict.copy()

Returns a shallow copy of a dictionary, creating a new dictionary with the same key-value pairs

dict.copy()

dict.fromkeys()

Creates a new dictionary with keys from an iterable and values set to a specified value

dict.fromkeys(iterable[, value])

dict.get()

Returns the value for a key, or a default value if the key is not found

dict.get(key[, default])

dict.items()

Returns a view object that displays a list of dictionary's key-value tuple pairs

dict.items()

dict.keys()

Returns a view object that displays a list of all keys in a dictionary

dict.keys()

dict.pop()

Removes and returns the value for a specified key, optionally with a default value if the key does not exist

dict.pop(key[, default])

dict.popitem()

Removes and returns the last key-value pair from a dictionary as a tuple

dict.popitem()

dict.setdefault()

Returns the value for a key, inserting a default if the key does not exist

dict.setdefault(key[, default])

dict.update()

Updates a dictionary with key-value pairs from another dictionary or iterable

dict.update([other])

dict.values()

Returns a view object that displays a list of all values in a dictionary

dict.values()