開発版ドキュメント · 0.2.3 30c2f8ba · 入門例の検証対象 0.2.3 · 版情報 · 既知の制限

gwexpy.table.SegmentCell#

class gwexpy.table.SegmentCell(value: Any | None = None, loader: Callable[[], Any] | None = None, cacheable: bool = True)#

ベースクラス: object

A 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.

is_loaded()

Return True if the value has been loaded (or was set directly).

Attributes

value: Any | None = None#
loader: Callable[[], Any] | None = None#
cacheable: bool = True#
get() Any#

Return the payload, loading it if necessary.

戻り値:

The resolved payload.

戻り値の型:

object

例外:

ValueError -- If both value and loader are None.

is_loaded() bool#

Return True if the value has been loaded (or was set directly).

clear() None#

Discard the cached value so the next get() call re-invokes the loader.