how can I clear a dictionary in python
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Wed Mar 28 19:27:30 EDT 2007
Marko.Cain.23 at gmail.com a écrit :
> Hi,
>
> I create a dictionary like this
> myDict = {}
>
> and I add entry like this:
> myDict['a'] = 1
> but how can I empty the whole dictionary?
>>> help(dict)
Help on class dict in module __builtin__:
class dict(object)
(...)
| Methods defined here:
(...)
|
| clear(...)
| D.clear() -> None. Remove all items from D.
(...)
>>>
>>> d = dict(a=1, b=2)
>>> d
{'a': 1, 'b': 2}
>>> d.clear()
>>> d
{}
>>>
More information about the Python-list
mailing list