Call :
>>> def Caller(func):
... func()
...
:
>>> def customTax(price, tax=0.16):
... return price + (price * tax)
...
:
>>> x = Caller(customTax(100))
Traceback (most recent call last):
File "", line 1, in
File "", line 2, in Caller
TypeError: 'float' object is not callable
ء Caller :
>>> def Caller(func, *funcargs):
... return func(*funcargs)
Caller * customTax :
>>> x = Caller(customTax, 100)
>>> x
116.0
:
>>> x = Caller(customTax, 100,0.12)
>>> x
112.0
:
>> def Welcome(who):
... print "Hello " + str(who)
( return) Caller x x ! ѡ None x interpreter print x :
>>> x = Caller(Welcome, 'Binary')
Hello Binary
:
None x :
None Welcome Python None :
>>> type(x)
<type 'NoneType'>
NoneType :
>>> Caller(Welcome, 'Binary')
Hello Binary
̡ Welcome
()