Python 如果不是唯一参数,则生成器表达式必须用括号括起来

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33137503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:50:19  来源:igfitidea点击:

Generator expression must be parenthesized if not sole argument

pythonpython-3.x

提问by Caleb Sandfort

I'm very new to Pythonand am trying to install the FuncDesignerpackage. It gives the following error:

我很新Python,正在尝试安装FuncDesigner包。它给出了以下错误:

Generator expression must be parenthesized if not sole argument and points to the following line:

如果不是唯一参数,则生成器表达式必须用括号括起来并指向以下行:

kw = {'skipArrayCast':True} if isComplexArray else {}
r = ooPoint((v, x[S.oovar_indexes[i]:S.oovar_indexes[i+1]]) for i, v in enumerate(S._variables), **kw)

Any ideas what to change the line starting with "r = "to to get it to work?

任何想法改变以“r =”开头的行以使其工作?

I'm using a Python 3version.

我正在使用一个Python 3版本。

回答by Ignacio Vazquez-Abrams

... Put the genex in parens, just like the error tells you to.

... 将基因放在括号中,就像错误告诉你的那样。

r = ooPoint(((v, x[S.oovar_indexes[i]:S.oovar_indexes[i+1]]) for i, v in enumerate(S._variables)), **kw)