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
Generator expression must be parenthesized if not sole argument
提问by Caleb Sandfort
I'm very new to Python
and 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 3
version.
我正在使用一个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)