views:

98

answers:

5

If the my_dict variable is global, you can't do:

my_dict = {}

that just create a new reference in the local scope.

Also, I found disgusting using the global keyword, so how can I empty a dict using its methods?

+3  A: 

you mean like .clear() ?

pycruft
+1  A: 
my_dict.clear()
Richard Fearn
+6  A: 

clear() mehtod?

http://docs.python.org/library/stdtypes.html#dict

Tao
+1  A: 

my_dict.clear()

ngroot
A: 

You may also check this one.

Zafer