sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Weird behavior in nested list comprehension #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

#atempt to use nested list comprehension
SIMPLE = '@'+'.'*2+('\n'+'.'*3)*2
SIMPLE = SIMPLE.split('\n')

#below fails with "SyntaxError: missing 'in' in list comprehension"
p = [['%s%d%d'%(p,x,y) for x, p in enumerate(' %s '%row)] for y, row in 
enumerate(SIMPLE)]

#attempt to workaround with function
def line(y,row):
 return ['%s%d%d'%(p,x,y) for x, p in enumerate(' %s '%row)]
#below fails with "ExecutionError too much recursion"
p = [[line(y,row)] for y, row in enumerate(SIMPLE)]

# possible workaround with for
p = []
for y,row in enumerate(SIMPLE):
 p = p + [line(y,row)]
 #below fails with "Erro: ExecutionError: p.__getattr__(...) is not a function"
 p.append([line(y,row)])

What is the expected output? What do you see instead?
expected : [[' 00','@10','.20','.30',' 40'],[' 01','.11','.21','.31',' 41'],[' 
02','.12','.22','.32',' 42']]

instead got runtime error

What version of the product are you using? On what operating system?
Brython version 1.0.20130126-094636
Ubuntu 11.10

Please provide any additional information below.
All attempts worked ok with ipython -> Python 2.7.2+

Original issue reported on code.google.com by cet...@gmail.com on 26 Jan 2013 at 4:20

GoogleCodeExporter commented 9 years ago
Thanks for the report
I am working on a rewriting of the Python to Javascript translator, this bug 
will be fixed when this work is finished (hopefully next weekend)
- Pierre

Original comment by pierre.q...@gmail.com on 28 Jan 2013 at 9:42

GoogleCodeExporter commented 9 years ago
Fixed in version 1.1

Original comment by pierre.q...@gmail.com on 16 Feb 2013 at 5:27