Thank you my friend! It was line 48. The 'sorted()' method transformed my dict in a list. I do need this approach to put the keys in a sorted way, but know I do it directly, like 'fromComboBox.addItems(sorted(rates.keys()))' and 'toComboBox.addItems(sorted(rates.keys()))', so that I don't overwrite my dict.
Final code working: http://pastebin.com/9vK1YBfA 3 USD to BRL from Google: 6.71 3 USD to BRL from my App: 6.71 3.50 Euro to YEN from Google: 478.50 3.50 Euro to YEN from my App: 478.67 Close enough, since it's a learning software, I don't need precise conversions, and it's not my fault, it's Bank Of Canada fault =p their CSV is a bit outdated. Thanks for the patience and not posting "take this code, it works", your way is much more helpful. 2014-08-31 0:27 GMT-03:00 Danny Yoo <d...@hashcollision.org>: > > > > Everything seems to be working, but, when I try to really use the program > > and convert something change the spinBox value I get: > > > > > > ### > > Traceback (most recent call last): > > File "C:/.../currency.py", line 20, in update_ui > > amount = (rates[from_] / rates[to]) * fromSpinBox.value() > > TypeError: list indices must be integers, not str > > ### > > > > What I have here is a DICT, not a LIST, why Python is reading it as a > list? > > I do need to pass a str (the currency names) to get the values from the > > dict. I'm reading the doc trying to figure this out. > > > > What statements affect the value of rates? Do a text search if you > have to. Search for anything that looks like "rates = "... > > Believe the error message unless something very unusual is happening. > Usually, Python is telling you the truth. You _know_ you were > dealing with a dictionary earlier. And yet, you also know, from the > error message, that something has changed "rates" from a dictionary to > a list. > > What statements in the program could have provoked this? I see at > least one in your program that probably will do it. I have no idea > what that particular statement is trying to do. >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor