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

2014-08-31 Thread Juan Christian
I'm changing so much the code that I got lost now. Code so far: http://pastebin.com/u4xwZuyJ I'm getting this error. 'value = float(row[-1])' is getting the values OK, but when I do 'rates[row[0]] = value' it screws things up. === Traceback (most recent call last): File

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

2014-08-31 Thread Juan Christian
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, ri

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

2014-08-31 Thread Juan Christian
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)

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

2014-08-31 Thread Juan Christian
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 overwrit

Re: [Tutor] Interacting with stderr

2014-08-31 Thread Crush
Alan said, "... you are reassigning p in the middle of a loop that depends on p. That's usually not a good idea..." If not what I changed my code to, then I reckon I do not understand what he is suggesting I do. I have to reparse stderr, each time test_loop.sh is executed the content of std

Re: [Tutor] Interacting with stderr

2014-08-31 Thread Alan Gauld
On 31/08/14 14:25, Crush wrote: Alan said, "... you are reassigning p in the middle of a loop that depends on p. That's usually not a good idea..." If not what I changed my code to, then I reckon I do not > understand what he is suggesting I do. Your original code looked like this: p = subpr

Re: [Tutor] reading strings and calculating totals

2014-08-31 Thread Alex Kleider
On 2014-08-30 13:13, Alan Gauld wrote: BUT, there is a much better way using Pythons for loop: total = 0 for line in infile: total += float(line) That automatically reads all the lines ion the file so you don't need to check for empty lines, set up the first line etc. infile.close()

[Tutor] calculate percents of items in a list

2014-08-31 Thread LN A-go-go
What would be a better way to calculate percentages of items in a list? please CountList = [9221382, 10374466, 5192905, 1710238, 3359] CL = [float(i) for i in CountList] CL sum = CL[0] + CL[1] + CL[2] + CL[3] + CL[4] import math perList = [] n = 0 def percentage(CL,sum): for i in CL: P

[Tutor] This is driving my crazy! My file hasn't been corrupted

2014-08-31 Thread Richard Dillon
My text file has five numbers, 1-5 I don't what the problem is. I've written the file using Word (saved as .txt ) as well as TextEdit Python 3.4.1 on a Mac Here's the code: # Richard Dillon # This program reads data from a .txt file and calculates a total # data in text file: 1,2,3,4 and 5

Re: [Tutor] This is driving my crazy! My file hasn't been corrupted

2014-08-31 Thread Chris “Kwpolska” Warrick
On Sun, Aug 31, 2014 at 6:31 PM, Richard Dillon wrote: > My text file has five numbers, 1-5 > I don't what the problem is. > I've written the file using Word (saved as .txt ) as well as TextEdit > Python 3.4.1 on a Mac We don’t really know either, without seeing the file. It probably has some un

Re: [Tutor] This is driving my crazy! My file hasn't been corrupted

2014-08-31 Thread Steven D'Aprano
On Sun, Aug 31, 2014 at 09:31:25AM -0700, Richard Dillon wrote: > My text file has five numbers, 1-5 > I don't what the problem is. You'll probably find out if you ask Python to show you what is actually causing the problem. > I've written the file using Word (saved as .txt ) as well as TextEd

Re: [Tutor] calculate percents of items in a list

2014-08-31 Thread Danny Yoo
On Aug 31, 2014 11:34 AM, "LN A-go-go" wrote: > > > What would be a better way to calculate percentages of items in a list? > please > Without showing us your code, try to explain a few examples of the problem you're trying to solve, and show us expected answer. The problem of just showing co

[Tutor] how import a module upon instantiation of a class?

2014-08-31 Thread Albert-Jan Roskam
Hi, I want to import a module upon instantiation (not definition) of a class. What is the best way to do this? In my case, I need the "icu" module in only one place/class of the program. If that class won't be used, I don't want to have an ImportError. Also, it might be nice to do the imports o

Re: [Tutor] reading strings and calculating totals

2014-08-31 Thread Alan Gauld
On 31/08/14 19:32, Alex Kleider wrote: total = 0 with open('/Users/richarddillon/Desktop/numbers.txt', 'r') as infile: for line in infile: total += float(line) print(total) ..but isn't there a problem if the file contains empty lines? Yes you are right. And my second reply did po

Re: [Tutor] how import a module upon instantiation of a class?

2014-08-31 Thread Peter Otten
Albert-Jan Roskam wrote: > I want to import a module upon instantiation (not definition) of a class. > What is the best way to do this? In my case, I need the "icu" module in > only one place/class of the program. If that class won't be used, I don't > want to have an ImportError. Also, it might b

Re: [Tutor] calculate percents of items in a list

2014-08-31 Thread Dave Angel
LN A-go-go Wrote in message: > Please post in text mode. It's a real pain trying to respond to the memory of your post. sum () is a built-in function that will add all the floats in CL. Of course you can't use it after you've overloaded it with a new meaning. In your loop, you refer to CL

[Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Juan Christian
I've been using PyCharm to code in Python but it seems a bit "overpowered" for this task, and there are some annoying bugs. I used Sublime Text 2 in the past, but it seems to be dead now (last update was JUN/2013), so I don't really know any good options. What do you guys use to code?

Re: [Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Steven D'Aprano
On Sun, Aug 31, 2014 at 09:12:24PM -0300, Juan Christian wrote: > I've been using PyCharm to code in Python but it seems a bit "overpowered" > for this task, and there are some annoying bugs. I used Sublime Text 2 in > the past, but it seems to be dead now (last update was JUN/2013), so I > don't r

Re: [Tutor] calculate percents of items in a list

2014-08-31 Thread Steven D'Aprano
On Sun, Aug 31, 2014 at 07:31:13PM -0400, Dave Angel wrote: > LN A-go-go Wrote in message: > > > > Please post in text mode. It's a real pain trying to respond to > the memory of your post. LN did post in text mode. Perhaps your email or news client is unable to deal with standard multipart/a

Re: [Tutor] calculate percents of items in a list

2014-08-31 Thread Steven D'Aprano
Hello, You seem to have deliberately set the Reply-To header for replies to go back to you, instead of allowing them to go to the mailing list for others to take part in the conversation. I don't know if that was you personally, or just another sign of the major suckage that is Yahoo mail, but

Re: [Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Juan Christian
I'm using Windows, but I do use Linux on a daily basis. On Sunday, August 31, 2014, Steven D'Aprano wrote: > On Sun, Aug 31, 2014 at 09:12:24PM -0300, Juan Christian wrote: > > I've been using PyCharm to code in Python but it seems a bit > "overpowered" > > for this task, and there are some anno

Re: [Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Cameron Simpson
On 01Sep2014 11:13, Steven D'Aprano wrote: On Sun, Aug 31, 2014 at 09:12:24PM -0300, Juan Christian wrote: I've been using PyCharm to code in Python but it seems a bit "overpowered" for this task, and there are some annoying bugs. I used Sublime Text 2 in the past, but it seems to be dead now (

Re: [Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Ben Finney
Juan Christian writes: > What [text editor] do you guys use to code? I use GNU Emacs primarily, and sometimes Vim. My recommendations have been posted in a different forum; I'll repeat them here. You can write Python code using any text editor. You will do well to use a text editor which is

Re: [Tutor] Good Text Editor/IDE for Python

2014-08-31 Thread Derek Jenkins
Juan, Besides Kwrite, I actually use the tools that the others mentioned so far, although I don't use Emacs often at all (perhaps I have just not found an advantageous use for it yet). So no real added info here, but I will say that I've not personally ran into any problems with Sublime. For Wind

Re: [Tutor] This is driving my crazy! My file hasn't been corrupted

2014-08-31 Thread David
On 1 September 2014 02:31, Richard Dillon wrote: > > except IOError: > print('An error occured trying to read the file.') > > except ValueError: > print('Non-numeric data found in the file.') > > except: > print('An error occured.') Your other respondents have