Question about idioms for clearing a list

Mel Wilson mwilson at the-wire.com
Mon Feb 6 16:07:21 EST 2006


Fredrik Lundh wrote:

> (del doesn't work on dictionaries)

... or rather [:] doesn't work on dictionaries ...

Python 2.4.2 (#1, Jan 23 2006, 21:24:54)
[GCC 3.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> d={'a':1, 'b':2, 'c':3}
 >>> print d
{'a': 1, 'c': 3, 'b': 2}
 >>> del d['b']
 >>> print d
{'a': 1, 'c': 3}
 >>> del d[:]
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: unhashable type
 >>>

	Regards.	Mel.



More information about the Python-list mailing list