2021-01-03 06:32:04 +03:00
|
|
|
def foo(default="bacon"):
|
2021-01-04 17:33:43 +03:00
|
|
|
print("You like",default,"right?")
|
2021-01-05 13:01:26 +03:00
|
|
|
def test():
|
|
|
|
print("hello")
|
|
|
|
return test
|
2021-01-03 06:32:04 +03:00
|
|
|
|
2021-03-11 13:05:21 +03:00
|
|
|
print('<function foo.<locals>.test' in str(foo()))
|
2021-01-03 06:32:04 +03:00
|
|
|
foo("sports")
|
|
|
|
|
|
|
|
def fillValues(a=1,b=2,c="c",d=None,e=2.71828):
|
2021-01-04 17:33:43 +03:00
|
|
|
print(a,b,c,d,e)
|
2021-01-03 06:32:04 +03:00
|
|
|
|
|
|
|
fillValues(b=True)
|
|
|
|
fillValues(c="test",a="one",e=object)
|
|
|
|
|
|
|
|
# Not like in Python! This is absolutely an anti-feature in Python.
|
|
|
|
def alwaysAFreshList(l=[]):
|
2021-01-04 17:33:43 +03:00
|
|
|
print("l=",l)
|
2021-01-03 06:32:04 +03:00
|
|
|
l.append(1)
|
2021-01-04 17:33:43 +03:00
|
|
|
print("l*=",l)
|
2021-01-03 06:32:04 +03:00
|
|
|
|
|
|
|
alwaysAFreshList()
|
|
|
|
alwaysAFreshList()
|
|
|
|
alwaysAFreshList([1,2,3])
|
|
|
|
alwaysAFreshList([1,2,3])
|
|
|
|
alwaysAFreshList()
|