我想简化我的代码,尤其是避免使用方括号;所以我的问题是:
def someFunction():
someString = "Hi!"
someNumber = 22
somePointer = ""
someList = []
names_list = ['someString','someNumber','somePointer','someList']
val_list = [someString, someNumber, somePointer, someList]
someDict = {}
for i in range( len( names_list ) ) :
someDict[names_list[i]] = val_list[i]
someOtherFunction( someDict )
def someOtherFunction( dict ):
for key, value in dict.iteritems() :
print key, value
print someString, someNumber
someFunction()
有可能做到这样吗?