If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it.
(self, method, *args)
| 153 | pass |
| 154 | |
| 155 | def _lazy(self, method, *args): |
| 156 | """ If the list is empty, calls lazylist.load(). |
| 157 | Replaces lazylist.method() with list.method() and calls it. |
| 158 | """ |
| 159 | if list.__len__(self) == 0: |
| 160 | self.load() |
| 161 | setattr(self, method, types.MethodType(getattr(list, method), self)) |
| 162 | return getattr(list, method)(self, *args) |
| 163 | |
| 164 | def __repr__(self): |
| 165 | return self._lazy("__repr__") |