File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ # 37-method-overloading-1.py
4
+
5
+ # Reference: O'Reilly Learning Path:
6
+ # http://shop.oreilly.com/product/0636920040057.do
7
+ # Chapter 24 : Method Overloading - Extending and Providing
8
+
9
+ import abc
10
+
11
+
12
+ class GetSetParent (object ):
13
+
14
+ __metaclass__ = abc .ABCMeta
15
+
16
+ def __init__ (self , value ):
17
+ self .val = 0
18
+
19
+ def set_val (self , value ):
20
+ self .val = value
21
+
22
+ def get_val (self ):
23
+ return self .val
24
+
25
+ @abc .abstractmethod
26
+ def showdoc (self ):
27
+ return
28
+
29
+
30
+ class GetSetList (GetSetParent ):
31
+ def __init__ (self , value = 0 ):
32
+ self .vallist = [value ]
33
+
34
+ def get_val (self ):
35
+ return self .vallist [- 1 ]
36
+
37
+ def get_vals (self ):
38
+ return self .vallist
39
+
40
+ def set_val (self , value ):
41
+ self .vallist .append (value )
42
+
43
+ def showdoc (self ):
44
+ print ("GetSetList object, len {0}, store history of values set" .format (
45
+ len (self .vallist )))
You can’t perform that action at this time.
0 commit comments