Commits

Alex Gaynor committed d76da24

Rewrite this code to be faster and more readable

Comments (0)

Files changed (1)

lib-python/2.7/uuid.py

         overriding the given 'hex', 'bytes', 'bytes_le', 'fields', or 'int'.
         """
 
-        if [hex, bytes, bytes_le, fields, int].count(None) != 4:
-            raise TypeError('need one of hex, bytes, bytes_le, fields, or int')
+        if (
+            ((hex is not None) + (bytes is not None) + (bytes_le is not None) +
+             (fields is not None) + (int is not None)) != 1
+        ):
+            raise TypeError('need exactly one of hex, bytes, bytes_le, fields,'
+                            ' or int')
         if hex is not None:
             hex = hex.replace('urn:', '').replace('uuid:', '')
             hex = hex.strip('{}').replace('-', '')