summaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
authorMarcel Bargull <marcel.bargull@udo.edu>2018-03-17 00:00:56 +0100
committerMarcel Bargull <marcel.bargull@udo.edu>2018-03-17 00:00:56 +0100
commit5cc97a07737bf08ccce187e04026002e62ce977f (patch)
tree9002324d5221efe7ee33ffee878514eb77b6005f /util.py
parent889ed48b4046dd187107a081cd07e00e9c8633f0 (diff)
downloadruamel.yaml-5cc97a07737bf08ccce187e04026002e62ce977f.tar.gz
add doc string for util.LazyEval
Diffstat (limited to 'util.py')
-rw-r--r--util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.py b/util.py
index 077b264..7a66947 100644
--- a/util.py
+++ b/util.py
@@ -17,6 +17,15 @@ if False: # MYPY
class LazyEval(object):
+ """
+ Lightweight wrapper around lazily evaluated func(*args, **kwargs).
+
+ func is only evaluated when any attribute of its return value is accessed.
+ Every attribute access is passed through to the wrapped value.
+ (This only excludes special cases like method-wrappers, e.g., __hash__.)
+ The sole additional attribute is the lazy_self function which holds the
+ return value (or, prior to evaluation, func and arguments), in its closure.
+ """
def __init__(self, func, *args, **kwargs):
def lazy_self():
return_value = func(*args, **kwargs)