summary refs log tree commit diff stats
path: root/ranger/ext/lazy_property.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/ext/lazy_property.py')
-rw-r--r--ranger/ext/lazy_property.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/ranger/ext/lazy_property.py b/ranger/ext/lazy_property.py
index 320a1993..734d9616 100644
--- a/ranger/ext/lazy_property.py
+++ b/ranger/ext/lazy_property.py
@@ -4,12 +4,17 @@ class lazy_property(object):
 	"""
 	A @property-like decorator with lazy evaluation
 
-	Example:
-	class Foo:
-		@lazy_property
-		def bar(self):
-			result = [...]
-			return result
+	>>> class Foo:
+	... 	@lazy_property
+	... 	def answer(self):
+	... 		print("calculating answer...")
+	... 		return 2*3*7
+	>>> foo = Foo()
+	>>> foo.answer
+	calculating answer...
+	42
+	>>> foo.answer
+	42
 	"""
 
 	def __init__(self, method):
@@ -23,3 +28,7 @@ class lazy_property(object):
 		result = self._method(obj)
 		obj.__dict__[self.__name__] = result
 		return result
+
+if __name__ == '__main__':
+	import doctest
+	doctest.testmod()
19:08 -0400 Add :exec and :pipe -b(ackground)' href='/akspecs/aerc/commit/commands/exec.go?id=7ecc6f96de5864d76ea2a94123b11c9258791cc9'>7ecc6f9 ^
6838c23 ^
7ecc6f9 ^


548a5ff ^
7ecc6f9 ^
548a5ff ^













7ecc6f9 ^


8ea86ce ^
7ecc6f9 ^
133085b ^
905cb9d ^






133085b ^
7ecc6f9 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64




                
            
                 
              
 
                                        







                           
                                   


                               
                                                                     


                  
                                                                 


                                                         
 
                                                 













                                                                                          


                                
                                                   
                        
                                                             






                                                                                     
                         



                  
51
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491