2021-01-03 10:02:50 +03:00
|
|
|
def anything(*args, **kwargs):
|
2021-01-05 13:01:26 +03:00
|
|
|
def foo():
|
|
|
|
print("hi")
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Positionals:", args)
|
|
|
|
print("Keywords:", kwargs)
|
2021-01-05 13:01:26 +03:00
|
|
|
return foo
|
2021-01-03 10:02:50 +03:00
|
|
|
|
2021-01-05 13:01:26 +03:00
|
|
|
anything(1,2,3,"a","b",foo="bar",biz=42)()
|
|
|
|
|
|
|
|
anything()()
|
2021-01-03 10:02:50 +03:00
|
|
|
|
|
|
|
def func(a,b,*args,**kwargs):
|
2021-01-04 17:33:43 +03:00
|
|
|
print(a, b, args)
|
2021-01-03 10:02:50 +03:00
|
|
|
let x = 'hello'
|
2021-01-04 17:33:43 +03:00
|
|
|
print(x)
|
2021-01-05 13:01:26 +03:00
|
|
|
return x
|
2021-01-03 10:02:50 +03:00
|
|
|
|
2021-01-05 13:01:26 +03:00
|
|
|
print(func(1,2,3,4,5,6,foo="bar"))
|
2021-01-03 10:02:50 +03:00
|
|
|
|
|
|
|
def last(a,b,c=1,d=2,**kwargs):
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Main:", a, b, c, d)
|
|
|
|
print("Keyword:", kwargs)
|
2021-01-03 10:02:50 +03:00
|
|
|
|
|
|
|
last(1,2)
|
|
|
|
last(1,2,7,3)
|
|
|
|
last(1,2,test="thing")
|
|
|
|
try:
|
|
|
|
last(1,2,'c','d',7,8,extra='foo')
|
2023-11-25 05:11:56 +03:00
|
|
|
except as exception:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(exception.arg)
|