Ste*_*ann 13 python python-3.6
这里发生了什么?
>>> list(map(lambda *x: x, *map(None, 'abc')))
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
list(map(lambda *x: x, *map(None, 'abc')))
TypeError: type object argument after * must be an iterable, not map
Run Code Online (Sandbox Code Playgroud)
忽略代码的无意义.这是关于错误消息,"可迭代,而不是映射".地图是可迭代的,不是吗?
如果我只能更换None同str,整个事情正常工作:
>>> list(map(lambda *x: x, *map(str, 'abc')))
[('a', 'b', 'c')]
Run Code Online (Sandbox Code Playgroud)
所以现在Python map毕竟没有任何问题.
这发生在我的Python 3.6.1中.我的Python 3.5.2反而提高了预期TypeError: 'NoneType' object is not callable.谷歌搜索"必须是可迭代的,而不是地图"根本找不到任何结果.显然这是最近才引入的.
这只是一个Python错误吗?或者这有什么意义吗?
更新: 按照建议立即报告为错误.
Ant*_*ile 11
我认为这是一个错误.这是导致此异常的源:
python字节码的反汇编确认它正在使用 BUILD_TUPLE_UNPACK_WITH_CALL
上面的"错误"中的代码是它假定任何 TypeError而_PyList_Extend荷兰国际集团参数数组意味着它不是一个可迭代,然而__iter__本身可引发TypeError.它正在重新抛出这个例外
我建议在https://bugs.python.org上打开一个错误