-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path_test_new_instance.py
73 lines (50 loc) · 1.43 KB
/
_test_new_instance.py
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
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
class PythonTest():
a = ''
def __init__(self):
self.a = 'initialized'
def logger(self, s):
self.a += '_' + s
return self.a
class PythonTest2(object):
def __init__(self, s):
self.a = s
def get_a(self):
return self.a
class PythonTest3():
v = "class_value"
@staticmethod
def get_static_value():
return PythonTest3.v
@staticmethod
def get_instance():
ins = PythonTest3()
ins.val1 = "test1"
return ins
@classmethod
def get_class_value(cls):
return cls.v
def get_instance_str(self):
return "instance method " + self.val1
@staticmethod
def get_instance2(a, b=5, **c):
ins = PythonTest3()
ins.a = a
ins.b = b
ins.c1 = c['v1']
return ins
def confirm(self):
return str(self.a) + '_' + str(self.b) + '_' + str(self.c1)
class ChildClass(PythonTest3):
v = "instance_value"
# ChildClass.get_class_value() will return "instance_value"
class PythonTestForKwd(object):
def __init__(self, a, b=5, **c):
self.a = a
self.b = b
self.c = c['c'] if 'c' in c else ''
self.d = c['d'] if 'd' in c else ''
self.e = c['e'] if 'e' in c else ''
def confirm_init(self):
return str(self.a) + '_' + str(self.b) + '_' + str(self.c) + '_' + \
str(self.d) + '_' + str(self.e)