Generators are compiled to js but do not work #75

Open
pyjsorg opened this Issue Apr 27, 2012 · 3 comments

Comments

Projects
None yet
1 participant
Contributor

pyjsorg commented Apr 27, 2012

Python 2.72, Windows 7, pyjamas 0.8alpha
Compiling with jyjs --translator=dict

The following code compiles fine but does not work at runtime in browser.


def createGenerator() :
mylist = range(3)
for i in mylist :
yield i*i

mygenerator = createGenerator() # create a generator
print(mygenerator) # mygenerator is an object !

for i in mygenerator:

print(i)

Expected output:
<generator object at 0x0143C968>
0
1
4

When opening in browser it prints none for the generator an alert box pops up with "hello: object is not iterable"

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=648 (September 25, 2011 20:01:54)

Contributor

pyjsorg commented Apr 27, 2012

From brian.ar...@gmail.com on December 05, 2011 06:14:04:
I'm getting 0 1 4 on firefox 8.0 and chrome 15.0.874, directly pasting your example.

mygenertor's repr, however, is "function () {}" on chrome and "function () {\n}" on firefox. I don't mean \n.

Contributor

pyjsorg commented Apr 27, 2012

From dennis.k...@gmail.com on December 05, 2011 16:50:09:
Hmm...it is still not working on my computer...perhaps I have some error in the configuration or so. But I am currently working on another project so I don't have the time to further analyse the problem. So I think this can be closed. Thanks for your help!

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on February 05, 2012 23:26:31:
neeh, we'll leave it open - someone else might encounter this. i'm putting it at "low priority" though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment