[Tutor] Proper uses of classes

2013-04-03 Thread frank ernest
Hi guys, it's been a while since I posted and I've learned a lot since then. Today I have a question on classes, I can't get mine to work. class alist(list): def __init__(self, b, a): self = list() self.append(b) a = a + b def appendit(self): self.append(a)   print(alist(2,4)) [] #It's blank

Re: [Tutor] Proper uses of classes

2013-04-03 Thread Dave Angel
On 04/03/2013 03:43 PM, frank ernest wrote: Hi guys, it's been a while since I posted and I've learned a lot since then. Today I have a question on classes, I can't get mine to work. Welcome back. I'll try. First comment is that indentation ought to be 4 columns, until you have enough exper

Re: [Tutor] Proper uses of classes

2013-04-03 Thread Alan Gauld
On 03/04/13 20:43, frank ernest wrote: Hi guys, it's been a while since I posted and I've learned a lot since then. Today I have a question on classes, I can't get mine to work. Dave has already addressed many issues but there are a few more to consider class alist(list): def __init__(s

[Tutor] Classes in multiple files

2013-04-03 Thread Phil
Thank you for reading this. The recent question relating to classes has prompted to ask this one. I have a main window class and a dialog class and they are defined in separate files. I'm attempting to display the dialog when a menu item is selected in the main window but it doesn't work becau

Re: [Tutor] Classes in multiple files

2013-04-03 Thread Alan Gauld
On 04/04/13 00:14, Phil wrote: If this was C++ then I'd need to include a class header and so I'm thinking that an import statement is needed in the main window class referring to the dialog class. Import SatelliteListDialog isn't correct. Reme,ber that in python its the file name you need to

[Tutor] Doubt in for loop

2013-04-03 Thread bessenkphilip
Hi all, I'm having a doubt in the below program's 2n'd "for" loop. >>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell through without finding a factor ...

Re: [Tutor] Classes in multiple files

2013-04-03 Thread Phil
On 04/04/13 09:32, Alan Gauld wrote: On 04/04/13 00:14, Phil wrote: If this was C++ then I'd need to include a class header and so I'm thinking that an import statement is needed in the main window class referring to the dialog class. Import SatelliteListDialog isn't correct. Reme,ber that in

Re: [Tutor] Classes in multiple files - code included

2013-04-03 Thread Phil
On 04/04/13 09:32, Alan Gauld wrote: Reme,ber that in python its the file name you need to use to import So if SatelliteListDialog is defined in satellite.py you need import satellite in your main window file. And satellite.py has to be in your library path too... The Eric IDE must take ca

Re: [Tutor] Doubt in for loop

2013-04-03 Thread Steven D'Aprano
On 04/04/13 12:29, bessenkphilip wrote: Hi all, I'm having a doubt in the below program's 2n'd "for" loop. for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell

Re: [Tutor] Classes in multiple files - code included

2013-04-03 Thread Steven D'Aprano
On 04/04/13 12:47, Phil wrote: And this is the error message; "global name 'Ui_satListDialog' is not defined" On its own, that is almost useless. Python gives you more debugging information than that: it gives you a complete traceback, which includes the actual line of code causing the prob

Re: [Tutor] Doubt in for loop

2013-04-03 Thread Dave Angel
On 04/03/2013 09:53 PM, Steven D'Aprano wrote: On 04/04/13 12:29, bessenkphilip wrote: Hi all, I'm having a doubt in the below program's 2n'd "for" loop. for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ...

Re: [Tutor] Doubt in for loop

2013-04-03 Thread antipode0
I believe Dave answered the OP's intended question. On Apr 3, 2013 9:54 PM, "Dave Angel" wrote: > On 04/03/2013 09:53 PM, Steven D'Aprano wrote: > >> On 04/04/13 12:29, bessenkphilip wrote: >> >>> Hi all, >>> >>> I'm having a doubt in the below program's 2n'd "for" loop. >>> >>> for n in range(2

Re: [Tutor] Classes in multiple files - code included

2013-04-03 Thread Phil
On 04/04/13 11:58, Steven D'Aprano wrote: On 04/04/13 12:47, Phil wrote: And this is the error message; "global name 'Ui_satListDialog' is not defined" On its own, that is almost useless. Python gives you more debugging information than that: it gives you a complete traceback, which include

Re: [Tutor] Classes in multiple files - code included

2013-04-03 Thread Peter Otten
Phil wrote: > I think I must be very close now so I'll post just the code that I think > is relevant. > > This the main window class: > import satListDialog Here you are importing the module "satListDialog" > class MainWindow(QMainWindow, Ui_MainWindow): > > This is the function to show the