[Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

Juan Christian juan0christian at gmail.com
Sun Aug 31 05:10:08 CEST 2014


Yes, the print, as I said, is DEBUG only.

The way you said works: http://pastebin.com/bqCjNZGH
Code: http://pastebin.com/9u2WCVat

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.


2014-08-30 23:58 GMT-03:00 Danny Yoo <dyoo at hashcollision.org>:

> On Sat, Aug 30, 2014 at 7:49 PM, Juan Christian
> <juan0christian at gmail.com> wrote:
> > Let's see, the print is just "debug", it's not necessary in the program.
> >
> > 'row[0]' is the first element of the current row. Ex.: row = ['a', 'b',
> 'c',
> > 'd'] - row[0] would be 'a'
> >
> > 'rates' is a dictionary, 'rates[row[0]]' would update the key row[0] in
> the
> > dict with the 'value'
> >
> > I think that's it, right?
>
>
> Close enough.  Let's look again now.
>
>                  print(rates[row[0]] + " / VALUE : " + str(value))
>                  rates[row[0]] = value
>
> The print statement here is trying to print the value for a record
> that hasn't been entered in yet.  So one way to naively fix this is to
> just switch the statements around:
>
>                 rates[row[0]] = value
>                 print(rates[row[0]] + " / VALUE : " + str(value))
>
> But that probably doesn't mean what you want.  Otherwise, you'd be
> printing the value _twice_ in your debugging output.  Try it out and
> you'll see what I mean.
>
> You probably meant to write:
>
>                  print(row[0] + " / VALUE : " + str(value))
>                  rates[row[0]] = value
>
> This is why human understanding is necessary here: it's all too easy
> to make a program run, but not make much sense.  Here, there are at
> least two ways to "fix" the erroneous situation, but only you can tell
> us the right thing to do is.
>
> That's why I asked very emphatically: what do you mean?  :P
>
>
> (And frankly, you probably don't want the print statement there in the
> first place: it's debugging output.  Right?)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140831/560778ae/attachment.html>


More information about the Tutor mailing list