pygritia.call module

Provides CallMixin mixin class It provides call support to the Lazy class

class pygritia.call.Call(target: Any, args: Tuple[Any, ...], kwargs: Mapping[str, Any])[source]

Bases: pygritia.core.LazyAction

Function call

args
evaluate(namespace: Mapping[Union[str, LazyMixin], Any]) → Any[source]

Evaluate expression

To substitute actual value for specific symbol, give value with keyword argument.

kwargs
target
class pygritia.call.CallMixin(action: pygritia.core.LazyAction, origin: Optional[LazyMixin] = None)[source]

Bases: pygritia.core.LazyMixin

Call support

Function call is read only expression

pygritia.call.lazy_call(func: _T) → _T[source]

Make a function to support lazy expression

>>> from pygritia import this, lazy_call, evaluate
>>> @lazy_call
... def hello(obj):
...     print(obj)
>>> print(hello(this))
hello(this)
>>> hello("123")
123
>>> evaluate(hello(this), {this: "123"})
123
pygritia.call.lazy_delattr(obj, name)

Lazy expression version of delattr

pygritia.call.lazy_delitem(a, b)

Lazy expression version of delitem

pygritia.call.lazy_getattr()

Lazy expression version of getattr

pygritia.call.lazy_getitem(a, b)

Lazy expression version of getitem

pygritia.call.lazy_setattr(obj, name, value)

Lazy expression version of setattr

pygritia.call.lazy_setitem(a, b, c)

Lazy expression version of setitem