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

allpy

view allpy/util.py @ 844:2ab571ea8101

blocks3d/wt: fix a typo in variable name current_taks -> current_tasks
author boris <bnagaev@gmail.com>
date Wed, 20 Jul 2011 02:46:23 +0200
parents 88b04c08f539
children 927085d03977
line source
1 """Miscellanous utilities.
2 """
3 import warnings
5 def unzip(seq):
6 """The oppozite of zip() builtin."""
7 a, b = [], []
8 for x, y in seq:
9 a.append(x)
10 b.append(y)
11 return a, b
13 def remove_each(string, substrings):
14 """Remove each of substrings from string."""
15 for sub in substrings:
16 string = string.replace(sub, "")
17 return string
19 class UserDict(dict):
20 """Clone of dict that user may add attributes to."""
21 pass
23 class UserList(list):
24 """Clone of list that user may add attributes to."""
25 pass
27 class UserString(str):
28 """Clone of str that user may add attributes to."""
29 pass
31 def deprecated(message):
32 """Warn about function being deprecated."""
33 warnings.warn(message, DeprecationWarning, stacklevel=2)
35 class lazy_import(object):
36 """Lazy module import to help breaking bad import loops."""
37 def __init__(self, name, globals={}, locals={}, fromlist=[], level=-1):
38 self.name = name
39 self.globals = globals
40 self.locals = locals
41 self.fromlist = fromlist
42 self.level = level
43 def __getattr__(self, attr):
44 self.module = __import__(
45 self.name, self.globals, self.locals, self.fromlist, self.level
46 )
47 self.__dict__ = self.module.__dict__
48 return self.__dict__[attr]
50 # vim: set et ts=4 sts=4 sw=4: