Set comprehensions don't work on Pydev (Python

2019-07-02 05:35发布

{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)

3条回答
一纸荒年 Trace。
2楼-- · 2019-07-02 05:41

Make sure that Pydev is configured to use Python 3.

查看更多
女痞
3楼-- · 2019-07-02 05:48

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

import sys
sys.stdout.write( sys.version )
查看更多
我命由我不由天
4楼-- · 2019-07-02 05:49

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!

查看更多
登录 后发表回答