Error : no viable alternative at input ‘for’ Python

I have strange problem,

when i am using Netbeans IDE , this line :

total_stock = {items : 0 for items in product_stock}

causes syntax Error:

Syntax Error : no viable alternative at input ‘for’

But the same code runs perfectly fine in terminal and returns this

>> {'rom_price': 0, 'rim_price': 0, 'ram_price': 0}

I am using python 2.7+ at terminal
and python plugin Version: 0.107 and Jython plugin Version: 2.12 Source: Python for netbeans 8.0

How to solve this problem??

Best answer

Looks like jython is not able to do dictionary comprehension. As a workaround use the dictionary constructor in combination with a generator.

total_stock = dict((item, 0) for item in product_stock)