假设我有这个:
a = {1: __class}
这个丑陋的片段a[1]()
是否有其他选择?
也尝试过a[1].__call__(argument)
,但PyCharm抱怨Expected type 'type', got X instead
在我看来,它击败了这一说法:
显式优于隐式
虽然a[1]()
没什么问题,但如果您真的想争论说它不够明确...
the_function_that_i_pulled_from_the_dictionary = a[1]
the_function_that_i_pulled_from_the_dictionary()