sgzwiz / brython

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

Boolean fails as list index, even with explicit integer typecast #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
x=[1,2]
#this is a possible workaround
print(x[1] if True else x[0])
#all these standard python expressions fail
print( x[4>2])
print(x[int(True)])
print(x[True])
What is the expected output? What do you see instead?
expected the number 2 printed four times

instead got an error:

2
TypeError: list indices must be integer, not <class 'bool'>
module '__main__' line 3
print( x[2>4])
<done in 23 ms>

What version of the product are you using? On what operating system?
Brython online console 24/01/2013

Please provide any additional information below.
Used for failproof execution in list comprehension 

Original issue reported on code.google.com by cet...@gmail.com on 24 Jan 2013 at 1:22

GoogleCodeExporter commented 9 years ago

Original comment by pierre.q...@gmail.com on 26 Jan 2013 at 6:26

GoogleCodeExporter commented 9 years ago
Thanks, it's fixed in revision 442

Original comment by pierre.q...@gmail.com on 26 Jan 2013 at 8:46