Home > other >  Use a dictionary and generation and decorator for help, abnormal results
Use a dictionary and generation and decorator for help, abnormal results

Time:09-23

G_dict=dict ()
Def the route (ABC) :
Def set_func (func) :
# from ABC for key variables, func for value
G_dict [ABC]=func
Def call_func () :
# return func ()
Pass
Return call_func
Return set_func

@ the route (" 111 ")
Def (a) :
Print (" the contents of the function ")
Return "OK"

Func=g_dict (" 111 ")
Print (" use a dictionary calls ", func ())
Print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ")
Print (" direct call ", (a))





I use # in the decorator return fuunc () pass blocked calls to the function

The results
The dictionary is bypassing the shielding, automatic call
  • Related