我已经在我的包中编写了这个函数。
def partitionIntoDays(ls, number, lookupKey=None):
''' Partitions the location measurements into days.
@ls: The list of measurements you want to partition
@return: A dictionary in the format {'Number of partition':
'List of measurements'}'''
if len(ls) == 0:
return {0: []}
firstMidnight = TimeAux.localTimeToEpoch(Delorean(TimeAux.epochToLocalTime(ls[0].time, TIMEZONE)).midnight())
return splitByTimedelta(ls, delta=number*24*3600, lowerBound=firstMidnight, lookupKey=lookupKey)
但是每当我尝试从脚本调用该函数时,都会收到以下错误:
TypeError: partitionIntoDays() got an unexpected keyword argument 'lookupKey'
但是,如果我手动将函数导入某处,我可以检查该函数是否具有参数。例如,我什至可以在 pdb 中调试上述错误时执行此操作。
import geogps.Partition as pt
pt.partitionIntoDays.func_code.co_varnames
>>>>('ls', 'number', 'lookupKey', 'firstMidnight')
上面的代码在 Python 3.4 中也可以正常工作。 简而言之,我完全惊呆了。
最佳答案
所以我想通了:虽然没有挥之不去的 pyc 文件,但我的包结构很困惑,并且嵌套文件夹中有一个无关的文件。 感谢@bruno-desthuilliers 为我指明了正确的方向。
关于python - "Unexpected"类型错误 : unexpected keyword,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32589928/