I was just playing around, and noticed that modules seem to be hashable.
Can anyone explain that, especially given the fact that they're mutable?
Python 2.3.3 (#1, May 7 2004, 10:31:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import sys
>>> hash(sys)[/color][/color][/color]
-150589324[color=blue][color=green][color=darkred]
>>> sys.x = 42
>>> hash(sys)[/color][/color][/color]
-150589324[color=blue][color=green][color=darkred]
>>> foo = {sys:'bar'}
>>> foo[sys][/color][/color][/color]
'bar'
Can anyone explain that, especially given the fact that they're mutable?
Python 2.3.3 (#1, May 7 2004, 10:31:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import sys
>>> hash(sys)[/color][/color][/color]
-150589324[color=blue][color=green][color=darkred]
>>> sys.x = 42
>>> hash(sys)[/color][/color][/color]
-150589324[color=blue][color=green][color=darkred]
>>> foo = {sys:'bar'}
>>> foo[sys][/color][/color][/color]
'bar'
Comment