MCPcopy Create free account
hub / github.com/clips/pattern / _lazy

Method _lazy

pattern/text/__init__.py:155–162  ·  view source on GitHub ↗

If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it.

(self, method, *args)

Source from the content-addressed store, hash-verified

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__")

Callers 9

__repr__Method · 0.95
__len__Method · 0.95
__iter__Method · 0.95
__contains__Method · 0.95
insertMethod · 0.95
appendMethod · 0.95
extendMethod · 0.95
removeMethod · 0.95
popMethod · 0.95

Calls 2

loadMethod · 0.95
__len__Method · 0.45

Tested by

no test coverage detected