allpy
annotate allpy/util.py @ 404:b5970add0bd9
graph.py: remove useless copy of edges
author | boris <bnagaev@gmail.com> |
---|---|
date | Mon, 07 Feb 2011 22:00:55 +0300 |
parents | e5c8deea6f83 |
children | 4bc2075d338a |
rev | line source |
---|---|
me@287 | 1 """Miscellanous utilities. |
me@287 | 2 """ |
me@287 | 3 |
me@287 | 4 def unzip(seq): |
me@304 | 5 """The oppozite of zip() builtin.""" |
me@287 | 6 a, b = [], [] |
me@287 | 7 for x, y in seq: |
me@287 | 8 a.append(x) |
me@287 | 9 b.append(y) |
me@287 | 10 return a, b |
me@287 | 11 |
me@305 | 12 def remove_each(string, substrings): |
me@305 | 13 """Remove each of substrings from string.""" |
me@305 | 14 for sub in substrings: |
me@305 | 15 string = string.replace(sub, "") |
me@305 | 16 return string |
me@305 | 17 |
me@293 | 18 class UserDict(dict): |
me@304 | 19 """Clone of dict that user may add attributes to.""" |
me@293 | 20 pass |
me@293 | 21 |
me@293 | 22 class UserList(list): |
me@304 | 23 """Clone of list that user may add attributes to.""" |
me@293 | 24 pass |
me@293 | 25 |
me@287 | 26 # vim: set et ts=4 sts=4 sw=4: |