diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index ac97a77225..cb25c72344 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -23,7 +23,7 @@ def unique(L1, L2): def indent(stream, numIndents, str): """ - Write str to stream with numIndents in front it it + Write str to stream with numIndents in front of it """ # To match emacs, instead of a tab character we will use 4 spaces stream.write(' ' * numIndents + str) @@ -348,6 +348,14 @@ def sameElements(a, b): return 0 return 1 +def list2dict(L, value=None): + """creates dict using elements of list, all assigned to same value""" + return dict([(k,value) for k in L]) + +def uniqueElements(L): + """are all elements of list unique?""" + return len(L) == len(list2dict(L)) + def contains(whole, sub): """ Return 1 if whole contains sub, 0 otherwise