gwexpy.table.SegmentCell#
- class gwexpy.table.SegmentCell(value: Any | None = None, loader: Callable[[], Any] | None = None, cacheable: bool = True)#
ベースクラス:
objectA single lazy-loadable payload cell.
- パラメータ:
value (Any | None) -- The concrete payload object. May be None when a loader is set.
loader (collections.abc.Callable[[], Any] | None) -- A zero-argument callable that returns the payload. Ignored when value is already set.
cacheable (bool) -- When True (default) the result of loader is stored in value after the first call, so subsequent calls return directly.
サンプル
>>> cell = SegmentCell(loader=lambda: 42, cacheable=True) >>> cell.get() 42 >>> cell.is_loaded() True
- __init__(value: Any | None = None, loader: Callable[[], Any] | None = None, cacheable: bool = True) None#
Methods
__init__([value, loader, cacheable])clear()Discard the cached value so the next
get()call re-invokes the loader.get()Return the payload, loading it if necessary.
Return
Trueif the value has been loaded (or was set directly).Attributes
- get() Any#
Return the payload, loading it if necessary.
- 戻り値:
The resolved payload.
- 戻り値の型:
- 例外:
ValueError -- If both value and loader are
None.