def func1(inputs=None): x = sum(inputs) return "sum some numbers: ", x ''' more functions ''' def func5(inputs=None): x_sq = 0 for x in inputs: x_sq += x**2 return "sum of squares: ", x_sq ''' more functions ''' def func8(inputs=None): return "hello from 8: ", inputs ''' more functions ''' a_list = [1,2,3,4,5,6,7,8,9,10] inputs = "test inputs" a_dict = {1:[func1([1,2,3]) ], 5:[func5([1,2,3])], 8:[func8("inputs to 8")]} needed = [1,5,8] for akey in needed: if akey in a_list: action = a_dict[akey] print "\naction: ", action
list = [f1...f32] needed = [f5(params), f6(params), f12(params)] for func in needed: if func in list: func(params)
>>> a_list = [1,2,3,4,5,6,7,8,9,10] >>> needed = [1,5,8] >>> for aval in needed: ... if aval in a_list: ... print "found ", aval ... found 1 found 5 found 8 >>>
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.