python - "Unexpected"类型错误 : unexpected keyword

标签 python python-2.7 typeerror keyword-argument

我已经在我的包中编写了这个函数。

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/

相关文章:

python - 为数值积分提供路径点

python - 将 Python 转换为 Scala

python - While 循环不断提示用户提供正确的输入类型

Python:从字符串中解析 ISO 8601 日期和时间(使用标准模块)

javascript - 类型错误:无法从未定义中读取属性 "1"

python - 如何在 Python 中重写 DataFrame 中的列的字段?

python-2.7 - 在 <fastCGI> 应用程序配置中找不到 Azure Flask <handler> scriptProcessor

python - 错误 : No similarly named formulae found. 错误:没有名称为 "python"的可用公式或桶

javascript - 上传文件 jquery 时未捕获类型错误

javascript - 类方法不是函数吗?