src/hdalab/utils.py
changeset 462 df8b3b49e81c
parent 345 7bc38c7d6cf9
child 492 19220d52bce7
--- a/src/hdalab/utils.py	Fri Feb 27 02:27:31 2015 +0100
+++ b/src/hdalab/utils.py	Sat Feb 28 06:40:48 2015 +0100
@@ -20,4 +20,13 @@
         cache_key = cache_key[:(250-(2+len(cache.key_prefix)+len(str(cache.version)))-33)] + '-' + hashlib.md5(cache_key).hexdigest()
     return cache_key
         
-        
\ No newline at end of file
+#
+# from : http://cs.stackexchange.com/a/10321
+#
+def toDigits(n, b):
+    """Convert a positive number n to its digit representation in base b."""
+    digits = []
+    while n > 0:
+        digits.insert(0, n % b)
+        n  = n // b
+    return digits
\ No newline at end of file