Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/a3e439d09322/allpy/util.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 20:41:19 2013
Кодировка:
allpy: a3e439d09322 allpy/util.py

allpy

view allpy/util.py @ 1087:a3e439d09322

Removed the unuzed allpy.util.lazy_import
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Thu, 31 May 2012 15:23:37 +0400
parents 87ba56d634cf
children c1091715f8a3
line source
1 """Miscellanous utilities.
2 """
3 import sys
4 import warnings
6 def unzip(seq):
7 """The oppozite of zip() builtin."""
8 a, b = [], []
9 for x, y in seq:
10 a.append(x)
11 b.append(y)
12 return a, b
14 def open(filename, mode='r'):
15 """Open file. Return stdin/stdout for filename '-'."""
16 if filename == '-':
17 if 'w' in mode or 'a' in mode or '+' in mode:
18 return sys.stdout
19 if 'r' in mode:
20 return sys.stdin
21 raise AssertionError("Unknown file mode: %s" % mode)
22 else:
23 return file(filename, mode)
25 def remove_each(string, substrings):
26 """Remove each of substrings from string."""
27 for sub in substrings:
28 string = string.replace(sub, "")
29 return string
31 class UserDict(dict):
32 """Clone of dict that user may add attributes to."""
33 pass
35 class UserList(list):
36 """Clone of list that user may add attributes to."""
37 pass
39 class UserString(str):
40 """Clone of str that user may add attributes to."""
41 pass
43 def deprecated(message):
44 """Warn about function being deprecated."""
45 warnings.warn(message, DeprecationWarning, stacklevel=2)
47 # vim: set et ts=4 sts=4 sw=4: