Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-17 12:11:27 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-17 12:11:27 (GMT)
commitf5b75c1aa86c0204f11ebca138e373c22221dc48 (patch)
tree695473d95134286ff6a192e5c1e26cc91c61107a /tautils.py
parent3c4a030ed6f4f04979889a5f7a3585d0e41d897a (diff)
moved misplaced methods to tautils
Diffstat (limited to 'tautils.py')
-rw-r--r--tautils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tautils.py b/tautils.py
index 12812db..77eb3f5 100644
--- a/tautils.py
+++ b/tautils.py
@@ -64,6 +64,23 @@ def convert(x, fn, try_ord=True):
return fn(xx)
return x
+def chr_to_ord(x):
+ """ Try to comvert a string to an ord """
+ if strtype(x) and len(x) == 1:
+ try:
+ return ord(x[0]), True
+ except ValueError:
+ return x, False
+ return x, False
+
+def strtype(x):
+ """ Is x a string type? """
+ if type(x) == str:
+ return True
+ if type(x) == unicode:
+ return True
+ return False
+
def magnitude(pos):
""" Calculate the magnitude of the distance between to blocks. """
x, y = pos