2021-01-03 06:09:41 +03:00
|
|
|
def function(positional1, positional2, keyword1=None, keyword2=None):
|
2021-01-04 17:33:43 +03:00
|
|
|
print(positional1, positional2)
|
|
|
|
print(keyword1, keyword2)
|
2021-01-03 06:09:41 +03:00
|
|
|
|
|
|
|
function(1,2)
|
|
|
|
function(1,2,3,4)
|
|
|
|
|
|
|
|
function(1,2,keyword2=5)
|
|
|
|
|
|
|
|
try:
|
|
|
|
function(1,keyword2=5)
|
|
|
|
except:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(exception.arg)
|
2021-01-03 06:09:41 +03:00
|
|
|
|
|
|
|
try:
|
|
|
|
function(1,2,positional1=4)
|
|
|
|
except:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(exception.arg)
|
2021-01-03 06:09:41 +03:00
|
|
|
|
|
|
|
try:
|
|
|
|
function(1,2,keyword2=None,keyword2=5)
|
|
|
|
except:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(exception.arg)
|
2021-01-03 06:09:41 +03:00
|
|
|
|
|
|
|
function(1,keyword2=4,positional2="abc")
|
|
|
|
|
|
|
|
try:
|
|
|
|
function(1,keyword2=4,keyword1=5,positional1="nope")
|
|
|
|
except:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(exception.arg)
|