Skip to content

Commit 45e3dd3

Browse files
Add files via upload
1 parent 3dbcd0d commit 45e3dd3

File tree

1 file changed

+92
-22
lines changed

1 file changed

+92
-22
lines changed

EXPR8.py

Lines changed: 92 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ def __init__(self,arg1,arg2):
88
print(Main('arg1','arg2').arg2)
99
except AttributeError:
1010
print('Attribute Error:')
11-
except TypeError:
12-
print('Type Error:')
13-
14-
11+
except NameError:
12+
print('Name Error:')
13+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1514
class Main:
1615
def __init__(self,*args):
1716

1817
self.args = args
1918

2019
try:
2120
print(Main('arg1','arg2').args[1])
21+
except NameError:
22+
print('Name Errror:')
2223
except IndexError:
23-
print('Index Errror:')
24-
25-
24+
print('Index Error:')
25+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2626
class Main:
2727
def __init__(self,arg1,arg2):
2828

@@ -32,18 +32,18 @@ def __init__(self,arg1,arg2):
3232
def return_args(arg1,arg2):
3333
return 'arg1','arg2'
3434

35-
Main = Main.return_args('argument placeholder','argument placeholder')
35+
Main = Main.return_args(
36+
'argument placeholder','argument placeholder')
3637

3738
try:
3839
print(Main[1])
3940
except AttributeError:
4041
print('Attribute Error:')
41-
except TypeError:
42-
print('Type Error:')
42+
except NameError:
43+
print('Name Error:')
4344
except IndexError:
4445
print('Index Error:')
45-
46-
46+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
4747
class Main:
4848
def __init__(self,arg1,arg2):
4949

@@ -55,18 +55,19 @@ def return_self(self):
5555

5656
def class_data(self):
5757
try:
58-
print(self.arg2)
58+
print(self.arg1)
5959
except AttributeError:
6060
print('Attribute Error:')
6161

6262
Main('arg1','arg2').class_data()
6363

6464
try:
6565
print(Main.return_self('Agument Placeholder Value')[1])
66+
except NameError:
67+
print('Name Error:')
6668
except IndexError:
6769
print('Index Error:')
68-
69-
70+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
7071
class Main:
7172
def __init__(self,arg1,arg2):
7273

@@ -76,39 +77,88 @@ def __init__(self,arg1,arg2):
7677
def return_args(*args):
7778
return args
7879

79-
Main = Main.return_args('args1','args2','args3','args4','args5')
80+
main = Main.return_args(
81+
'args1','args2','args3','args4','args5')
8082

8183
try:
82-
print(Main[4])
84+
print(main[4])
85+
except NameError:
86+
print('Name Error:')
8387
except IndexError:
8488
print('Index Error:')
85-
86-
89+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
8790
class Main:
8891
def __init__(self,arg1,arg2):
8992

9093
self.arg1 = arg1
9194
self.arg2 = arg2
9295

93-
def return_keyword_arguments(**kwargs):
96+
def return_keyword_args(**kwargs):
9497
return kwargs
9598

96-
Main = Main.return_keyword_arguments(
99+
Main = Main.return_keyword_args(
97100
kwargs1 = 'karg1',kwargs2 = 'karg2',
98101
kwargs3 = 'karg3',kwargs4 = 'karg4'
99102
)
100103

101104
print(Main.get('kwargs4','Attribute Not Found:'))
105+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
106+
class Main:
107+
def __init__(self,**kwargs):
108+
109+
self.args = kwargs
102110

111+
def return_keyword_args(**kwargs):
112+
return kwargs
103113

114+
main = Main.return_keyword_args(
115+
kwargs1 = 'karg1',kwargs2 = 'karg2',
116+
kwargs3 = 'karg3',kwargs4 = 'karg4'
117+
)
118+
119+
print(main.get('kwargs4','Attribute Not Found:'))
120+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
121+
class Main:
122+
def __init__(self,**kwargs):
123+
124+
self.kwargs = kwargs
125+
126+
class Sub(Main):pass
127+
128+
main = Sub(
129+
kwargs1 = 'keyword argument1',
130+
kwargs2 = 'keyword argument2',
131+
kwargs3 = 'keyword argument3')
132+
133+
print(main.kwargs.get('kwargs3','Attribute Not Found:'))
134+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
135+
class Main:
136+
def __init__(self,**kwargs):
137+
138+
self.__dict__.update(kwargs)
139+
140+
class Sub(Main):pass
141+
142+
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:')
153+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
104154
class Main:
105155
def __init__(self,*args):
106156

107157
self.args = args
108158

109159
def class_data(self):
110160
try:
111-
print(self.args[6])
161+
print(self.args[8])
112162
except IndexError:
113163
print('Index Error:')
114164

@@ -117,3 +167,23 @@ def class_data(self):
117167
'arg4','arg5','arg6',
118168
'arg7','arg8','arg9'
119169
).class_data()
170+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
171+
class Main:
172+
def __init__(self,**kwargs):
173+
174+
self.kwargs = kwargs
175+
176+
def class_data(self):
177+
178+
try:
179+
print(self.kwargs.get('kwargs5','Attribute Not Found:'))
180+
except IndexError:
181+
print('Index Error:')
182+
183+
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'
189+
).class_data()

0 commit comments

Comments
 (0)