Skip to content

Commit 553de80

Browse files
Add files via upload
1 parent 45e3dd3 commit 553de80

File tree

1 file changed

+240
-66
lines changed

1 file changed

+240
-66
lines changed

EXPR8.py

Lines changed: 240 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,14 @@ def __init__(self,arg1,arg2):
44
self.arg1 = arg1
55
self.arg2 = arg2
66

7-
try:
8-
print(Main('arg1','arg2').arg2)
9-
except AttributeError:
10-
print('Attribute Error:')
11-
except NameError:
12-
print('Name Error:')
7+
print(Main('arg1','arg2').arg1)
138
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
149
class Main:
1510
def __init__(self,*args):
1611

1712
self.args = args
1813

19-
try:
20-
print(Main('arg1','arg2').args[1])
21-
except NameError:
22-
print('Name Errror:')
23-
except IndexError:
24-
print('Index Error:')
14+
print(Main('arg1','arg2').args[0])
2515
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2616
class Main:
2717
def __init__(self,arg1,arg2):
@@ -35,14 +25,7 @@ def return_args(arg1,arg2):
3525
Main = Main.return_args(
3626
'argument placeholder','argument placeholder')
3727

38-
try:
39-
print(Main[1])
40-
except AttributeError:
41-
print('Attribute Error:')
42-
except NameError:
43-
print('Name Error:')
44-
except IndexError:
45-
print('Index Error:')
28+
print(Main[0])
4629
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
4730
class Main:
4831
def __init__(self,arg1,arg2):
@@ -61,12 +44,7 @@ def class_data(self):
6144

6245
Main('arg1','arg2').class_data()
6346

64-
try:
65-
print(Main.return_self('Agument Placeholder Value')[1])
66-
except NameError:
67-
print('Name Error:')
68-
except IndexError:
69-
print('Index Error:')
47+
print(Main.return_self('Agument Placeholder Value')[0])
7048
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
7149
class Main:
7250
def __init__(self,arg1,arg2):
@@ -80,12 +58,7 @@ def return_args(*args):
8058
main = Main.return_args(
8159
'args1','args2','args3','args4','args5')
8260

83-
try:
84-
print(main[4])
85-
except NameError:
86-
print('Name Error:')
87-
except IndexError:
88-
print('Index Error:')
61+
print(main[4])
8962
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
9063
class Main:
9164
def __init__(self,arg1,arg2):
@@ -97,11 +70,11 @@ def return_keyword_args(**kwargs):
9770
return kwargs
9871

9972
Main = Main.return_keyword_args(
100-
kwargs1 = 'karg1',kwargs2 = 'karg2',
101-
kwargs3 = 'karg3',kwargs4 = 'karg4'
73+
kwarg1 = 'karg1',kwarg2 = 'karg2',
74+
kwarg3 = 'karg3',kwarg4 = 'karg4'
10275
)
10376

104-
print(Main.get('kwargs4','Attribute Not Found:'))
77+
print(Main.get('kwarg4','Attribute Not Found:'))
10578
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
10679
class Main:
10780
def __init__(self,**kwargs):
@@ -112,11 +85,11 @@ def return_keyword_args(**kwargs):
11285
return kwargs
11386

11487
main = Main.return_keyword_args(
115-
kwargs1 = 'karg1',kwargs2 = 'karg2',
116-
kwargs3 = 'karg3',kwargs4 = 'karg4'
88+
kwarg1 = 'karg1',kwarg2 = 'karg2',
89+
kwarg3 = 'karg3',kwarg4 = 'karg4'
11790
)
11891

119-
print(main.get('kwargs4','Attribute Not Found:'))
92+
print(main.get('kwarg3','Attribute Not Found:'))
12093
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
12194
class Main:
12295
def __init__(self,**kwargs):
@@ -126,11 +99,11 @@ def __init__(self,**kwargs):
12699
class Sub(Main):pass
127100

128101
main = Sub(
129-
kwargs1 = 'keyword argument1',
130-
kwargs2 = 'keyword argument2',
131-
kwargs3 = 'keyword argument3')
102+
kwarg1 = 'keyword argument1',
103+
kwarg2 = 'keyword argument2',
104+
kwarg3 = 'keyword argument3')
132105

133-
print(main.kwargs.get('kwargs3','Attribute Not Found:'))
106+
print(main.kwargs.get('kwarg3','Attribute Not Found:'))
134107
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
135108
class Main:
136109
def __init__(self,**kwargs):
@@ -140,27 +113,19 @@ def __init__(self,**kwargs):
140113
class Sub(Main):pass
141114

142115
main = Main(
143-
kwargs1 = 'keyword argument1',
144-
kwargs2 = 'keyword argument2',
145-
kwargs3 = 'keyword argument3')
146-
147-
try:
148-
print(main.kwargs3)
149-
except AttributeError:
150-
print('Attribute Error:')
151-
except NameError:
152-
print('Name Error:')
116+
kwarg1 = 'keyword argument1',
117+
kwarg2 = 'keyword argument2',
118+
kwarg3 = 'keyword argument3')
119+
120+
print(main.kwarg1)
153121
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
154122
class Main:
155123
def __init__(self,*args):
156124

157125
self.args = args
158126

159127
def class_data(self):
160-
try:
161-
print(self.args[8])
162-
except IndexError:
163-
print('Index Error:')
128+
print(self.args[0])
164129

165130
Main(
166131
'arg1','arg2','arg3',
@@ -174,16 +139,225 @@ def __init__(self,**kwargs):
174139
self.kwargs = kwargs
175140

176141
def class_data(self):
177-
178-
try:
179-
print(self.kwargs.get('kwargs5','Attribute Not Found:'))
180-
except IndexError:
181-
print('Index Error:')
142+
print(self.kwargs.get('kwarg5','Attribute Not Found:'))
182143

183144
Main(
184-
kwargs1 = 'karg1',kwargs2 = 'karg2',
185-
kwargs3 = 'karg3',kwargs4 = 'karg4',
186-
kwargs5 = 'karg5',kwargs6 = 'karg6',
187-
kwargs7 = 'karg7',kwargs8 = 'karg8',
188-
kwargs9 = 'karg9',kwargs10 = 'karg10'
145+
kwarg1 = 'karg1',kwarg2 = 'karg2',
146+
kwarg3 = 'karg3',kwarg4 = 'karg4',
147+
kwarg5 = 'karg5',kwarg6 = 'karg6',
148+
kwarg7 = 'karg7',kwarg8 = 'karg8',
149+
kwarg9 = 'karg9',kwarg10 = 'karg10'
189150
).class_data()
151+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
152+
class Main:
153+
154+
def __init__(self,attribute1,attribute2):
155+
156+
self.attribute1 = attribute1
157+
self.attribute2 = attribute2
158+
159+
def return_value(variable_value):
160+
return 'Returned Variable Value from Main.'
161+
162+
class Superclass1(Main):
163+
164+
def __init__(self,attribute1,attribute2):
165+
super().__init__(attribute1,attribute2)
166+
167+
class Superclass2(Main):
168+
169+
def __init__(
170+
self,attribute1,attribute2,attribute3,attribute4):
171+
super().__init__(attribute1,attribute2)
172+
173+
self.attribute3 = attribute3
174+
self.attribute4 = attribute4
175+
176+
class_attribute_values = Main(
177+
'I am the attribute property value of attribute1',
178+
'I am the attribute property value of attribute2')
179+
180+
superclass1_attribute_values = Superclass1(
181+
'I am the attribute property value of attribute1',
182+
'I am the attribute property value of attribute2')
183+
184+
superclass2_attribute_values = Superclass2(
185+
'I am the attribute property value of attribute1',
186+
'I am the attribute property value of attribute2',
187+
'I am the attribute property value of attribute3',
188+
'I am the attribute property value of attribute4')
189+
190+
return_value1 = Main.return_value('argument placeholder')
191+
192+
return_value2 = Superclass1.return_value('argument placeholder')
193+
194+
return_value3 = Superclass2.return_value('argument placeholder')
195+
196+
print(class_attribute_values.attribute1)
197+
198+
print(superclass1_attribute_values.attribute1)
199+
200+
print(superclass2_attribute_values.attribute1)
201+
202+
print(return_value1)
203+
print(return_value2)
204+
print(return_value3)
205+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
206+
class Main:
207+
208+
def __init__(self,*args):
209+
210+
self.args = args
211+
212+
def return_value(variable_value):
213+
return 'Returned Variable Value from Main.'
214+
215+
class Superclass1(Main):
216+
217+
def __init__(self,*args):
218+
super().__init__(*args)
219+
220+
self.args = args
221+
222+
class Superclass2(Main):
223+
224+
def __init__(self,*args):
225+
super().__init__(*args)
226+
227+
self.args = args
228+
229+
class_attribute_values = Main(
230+
'I am the attribute property value of attribute1',
231+
'I am the attribute property value of attribute2')
232+
233+
superclass1_attribute_values = Superclass1(
234+
'I am the attribute property value of attribute1',
235+
'I am the attribute property value of attribute2')
236+
237+
superclass2_attribute_values = Superclass2(
238+
'I am the attribute property value of attribute1',
239+
'I am the attribute property value of attribute2',
240+
'I am the attribute property value of attribute3',
241+
'I am the attribute property value of attribute4')
242+
243+
return_value1 = Main.return_value('argument placeholder')
244+
245+
return_value2 = Superclass1.return_value('argument placeholder')
246+
247+
return_value3 = Superclass2.return_value('argument placeholder')
248+
249+
print(class_attribute_values.args[0])
250+
251+
print(superclass1_attribute_values.args[0])
252+
253+
print(superclass2_attribute_values.args[0])
254+
255+
print(return_value1)
256+
print(return_value2)
257+
print(return_value3)
258+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
259+
class Main:
260+
261+
def __init__(self,**kwargs):
262+
263+
self.kwargs = kwargs
264+
265+
def return_value(variable_value):
266+
return 'Returned Variable Value from Main.'
267+
268+
class Superclass1(Main):
269+
270+
def __init__(self,**kwargs):
271+
super().__init__(**kwargs)
272+
273+
self.kwargs = kwargs
274+
275+
class Superclass2(Main):
276+
277+
def __init__(self,**kwargs):
278+
super().__init__(**kwargs)
279+
280+
self.kwargs = kwargs
281+
282+
class_attribute_values = Main(
283+
kwarg1 = 'I am the attribute property value of attribute1',
284+
kwarg2 = 'I am the attribute property value of attribute2')
285+
286+
superclass1_attribute_values = Superclass1(
287+
kwarg1 = 'I am the attribute property value of attribute1',
288+
kwarg2 = 'I am the attribute property value of attribute2')
289+
290+
superclass2_attribute_values = Superclass2(
291+
kwarg1 = 'I am the attribute property value of attribute1',
292+
kwarg2 = 'I am the attribute property value of attribute2',
293+
kwarg3 = 'I am the attribute property value of attribute3',
294+
kwarg4 = 'I am the attribute property value of attribute4')
295+
296+
return_value1 = Main.return_value('argument placeholder')
297+
298+
return_value2 = Superclass1.return_value('argument placeholder')
299+
300+
return_value3 = Superclass2.return_value('argument placeholder')
301+
302+
print(class_attribute_values.kwargs.get('kwarg1','Attribute Not Found:'))
303+
304+
print(superclass1_attribute_values.kwargs.get('kwarg1','Attribute Not Found:'))
305+
306+
print(superclass2_attribute_values.kwargs.get('kwarg1','Attribute Not Found:'))
307+
308+
print(return_value1)
309+
print(return_value2)
310+
print(return_value3)
311+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
312+
class Main:
313+
314+
def __init__(self,**kwargs):
315+
316+
self.__dict__.update(kwargs)
317+
318+
def return_value(variable_value):
319+
return 'Returned Variable Value from Main.'
320+
321+
class Superclass1(Main):
322+
323+
def __init__(self,**kwargs):
324+
super().__init__(**kwargs)
325+
326+
self.kwargs = kwargs
327+
328+
class Superclass2(Main):
329+
330+
def __init__(self,**kwargs):
331+
super().__init__(**kwargs)
332+
333+
self.kwargs = kwargs
334+
335+
class_attribute_values = Main(
336+
kwarg1 = 'I am the attribute property value of attribute1',
337+
kwarg2 = 'I am the attribute property value of attribute2')
338+
339+
superclass1_attribute_values = Superclass1(
340+
kwarg1 = 'I am the attribute property value of attribute1',
341+
kwarg2 = 'I am the attribute property value of attribute2')
342+
343+
superclass2_attribute_values = Superclass2(
344+
kwarg1 = 'I am the attribute property value of attribute1',
345+
kwarg2 = 'I am the attribute property value of attribute2',
346+
kwarg3 = 'I am the attribute property value of attribute3',
347+
kwarg4 = 'I am the attribute property value of attribute4')
348+
349+
return_value1 = Main.return_value('argument placeholder')
350+
351+
return_value2 = Superclass1.return_value('argument placeholder')
352+
353+
return_value3 = Superclass2.return_value('argument placeholder')
354+
355+
print(class_attribute_values.kwarg1)
356+
357+
print(superclass1_attribute_values.kwarg1)
358+
359+
print(superclass2_attribute_values.kwarg1)
360+
361+
print(return_value1)
362+
print(return_value2)
363+
print(return_value3)

0 commit comments

Comments
 (0)