1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
Description: Use a list of tuples instead of depending on dict iteration order
Author: Stefano Rivera <stefanor@debian.org>
Bug-Debian: http://bugs.debian.org/617966
Bug-Ubuntu: https://bugs.launchpad.net/bugs/719708
Forwarded: yes
Last-Update: 2011-03-23
--- a/src/typeToolBox.py
+++ b/src/typeToolBox.py
@@ -20,14 +20,14 @@
# Supported types
# 'bool' type must be placed *before* 'int' type, otherwise booleans are detected as integers
-types = {bool : 'bool', int : 'int', str : 'str'}
+types = [(bool, 'bool'), (int, 'int'), (str, 'str')]
# Return a String with the type of value
def getType(value) :
- for type in types.keys() :
+ for type, name in types:
if isinstance(value, type) :
- return types[type]
+ return name
raise TypeError, str(value) + _(' has an unsupported type')
|