speaklater.py
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class LazyString(object):
def __init__(self, func, *args, **kwargs):
self._func = func
self._args = args
self._kwargs = kwargs
def __getattr__(self, attr):
if attr == "__setstate__":
raise AttributeError(attr)
string = str(self)
if hasattr(string, attr):
return getattr(string, attr)
raise AttributeError(attr)
def __repr__(self):
return "l'{0}'".format(str(self))
def __str__(self):
return str(self._func(*self._args, **self._kwargs))
def __len__(self):
return len(str(self))
def __getitem__(self, key):
return str(self)[key]
def __iter__(self):
return iter(str(self))
def __contains__(self, item):
return item in str(self)
def __add__(self, other):
return str(self) + other
def __radd__(self, other):
return other + str(self)
def __mul__(self, other):
return str(self) * other
def __rmul__(self, other):
return other * str(self)
def __lt__(self, other):
return str(self) < other
def __le__(self, other):
return str(self) <= other
def __eq__(self, other):
return str(self) == other
def __ne__(self, other):
return str(self) != other
def __gt__(self, other):
return str(self) > other
def __ge__(self, other):
return str(self) >= other
def __html__(self):
return str(self)
def __hash__(self):
return hash(str(self))
def __mod__(self, other):
return str(self) % other
def __rmod__(self, other):
return other + str(self)