how can I clear a dictionary in python

Aahz aahz at pythoncraft.com
Wed Mar 28 18:51:58 EDT 2007


In article <4_SdndYI-pFUbZfbnZ2dnUVZ_hzinZ2d at comcast.com>,
Larry Bates  <lbates at websafe.com> wrote:
>Marko.Cain.23 at gmail.com wrote:
>> 
>> I create a dictionary like this
>> myDict = {}
>> 
>> and I add entry like this:
>> myDict['a'] = 1
>> but how can I empty the whole dictionary?
>
>just point myDict to an empty dictionary again
>
>myDict={}

Go back and read Christian's post, then post a followup explaning why his
solution is better than yours.  Your explanation should use id().
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Need a book?  Use your library!



More information about the Python-list mailing list