Set comprehensions don't work on Pydev (Python)

半世苍凉 提交于 2019-12-12 13:41:23

问题


{x for x in range(10)}

works perfectly on IDLE, but when I try this in eclipse (with Pydev plugin) I get a syntax error:

Undefined variable: x

Is it because Pydev doesn't support set comprehensions or something? What can I do to make this work? (This was just one example that doesn't work. All set comprehensions don't work for me).

(I'm using Python 3)


回答1:


This is a bug in PyDev; in this case ignore the editor's warning and execute the code: it will work.

I get this a lot, PyDev isn't perfect but it's good enough!




回答2:


Make sure that Pydev is configured to use Python 3.




回答3:


You can find out which version of Python you are using with

import sys
sys.stdout.write( sys.version )


来源:https://stackoverflow.com/questions/3576927/set-comprehensions-dont-work-on-pydev-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!