@@ -70,30 +70,39 @@ def parents(self):
70
70
71
71
72
72
def main ():
73
- Jhon = Person ('Jhon' , 'Coder' )
74
- print (u"Name: {0} Occupation: {1}" .format (Jhon .name , Jhon .occupation ))
75
- print (u"Before we access `relatives`:" )
76
- print (Jhon .__dict__ )
77
- print (u"Jhon's relatives: {0}" .format (Jhon .relatives ))
78
- print (u"After we've accessed `relatives`:" )
79
- print (Jhon .__dict__ )
80
- print (Jhon .parents )
81
- print (Jhon .__dict__ )
82
- print (Jhon .parents )
83
- print (Jhon .call_count2 )
84
-
85
-
86
- if __name__ == '__main__' :
87
- main ()
88
-
89
- ### OUTPUT ###
90
- # Name: Jhon Occupation: Coder
91
- # Before we access `relatives`:
92
- # {'call_count2': 0, 'name': 'Jhon', 'occupation': 'Coder'}
93
- # Jhon's relatives: Many relatives.
94
- # After we've accessed `relatives`:
95
- # {'relatives': 'Many relatives.', 'call_count2': 0, 'name': 'Jhon', 'occupation': 'Coder'}
96
- # Father and mother
97
- # {'_lazy__parents': 'Father and mother', 'relatives': 'Many relatives.', 'call_count2': 1, 'name': 'Jhon', 'occupation': 'Coder'} # noqa flake8
98
- # Father and mother
99
- # 1
73
+ """
74
+ >>> Jhon = Person('Jhon', 'Coder')
75
+
76
+ >>> Jhon.name
77
+ 'Jhon'
78
+ >>> Jhon.occupation
79
+ 'Coder'
80
+
81
+ # Before we access `relatives`
82
+ >>> sorted(Jhon.__dict__.items())
83
+ [('call_count2', 0), ('name', 'Jhon'), ('occupation', 'Coder')]
84
+
85
+ >>> Jhon.relatives
86
+ 'Many relatives.'
87
+
88
+ # After we've accessed `relatives`
89
+ >>> sorted(Jhon.__dict__.items())
90
+ [('call_count2', 0), ..., ('relatives', 'Many relatives.')]
91
+
92
+ >>> Jhon.parents
93
+ 'Father and mother'
94
+
95
+ >>> sorted(Jhon.__dict__.items())
96
+ [('_lazy__parents', 'Father and mother'), ('call_count2', 1), ..., ('relatives', 'Many relatives.')]
97
+
98
+ >>> Jhon.parents
99
+ 'Father and mother'
100
+
101
+ >>> Jhon.call_count2
102
+ 1
103
+ """
104
+
105
+
106
+ if __name__ == "__main__" :
107
+ import doctest
108
+ doctest .testmod (optionflags = doctest .ELLIPSIS )
0 commit comments