Built-in Methods in Dictionary
Following Table lists the methods for dictionary objects. The clear(), copy(), get(), and update() methods were added recently in Python 1.5. setdefault() was introduced in 2.0.
Dictionary Type Methods
dictionary method | Operation |
---|---|
dict.clear() | appends object obj to list |
dict.copy() | returns count of how many times obj occurs in list |
dict.get(key,default=None) | appends the contents of seq to list |
dict.has_key(key) | returns the lowest index in list that obj appears |
dict.items() | inserts object obj into list at offset index |
dict.keys() | removes and returns last object or obj from list |
list.remove(obj) | removes object obj from list |
dict.setdefault key,default=None) | reverses objects of list in place |
dict.values() | returns list of dictionary dict’s values |
dict.update(dict2) | sorts objects of list, use compare func if given |