Re: [Tutor] a little loop

2013-05-27 Thread John Steedman
Some other tools, if you haven't come across them yet. You already know about str.join () Slicing >>>b=['s','p','a','m'] b [ : 1 ] ['s'] b [ : 2 ] ['s', 'p'] Also, consider >>>len ( b) 4 >>>range ( 4 ) [ 0, 1, 2, 3, 4] # which I can iterate over. On Tue, May 28, 2013 at 4:54 AM, T

Re: [Tutor] a little loop

2013-05-27 Thread kartik sundarajan
One way I can suggest is x=0; ham=''; b=['s','p','a','m'] #or, b=('s','p','a','m') > for t in b: > ham=ham+b[x] > print(ham);x+=1 > > > 't' is actually equal to b[x] and its faster then indexed based look-up. so you can rewrite ham = ham + b[x] as ham += t and remove the x inc

[Tutor] a little loop

2013-05-27 Thread Tim Hanson
Okay, so I made it to FOR loops in the Lutz book. A couple of days ago I was helped here with the .join method for creating strings from lists or tuples of strings. I got to wondering if I could just, for the sake of learning, do the same thing in a FOR loop, since that's today's chapter: x=0

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread eryksun
On Mon, May 27, 2013 at 4:01 PM, Jim Mooney wrote: > I was looking at the bytecode doc page as a break from the Lutz book, > since I like Assembler-type code due to its total non-ambiguity, but > the page doesn't say much. Is there a doc somewhere that corresponds > some of the bytecode to Python

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Dave Angel
On 05/27/2013 07:56 PM, ALAN GAULD wrote: I can't speak for Jim, but I have used the dis module in the past to quickly check how python parsed an expression (e.g. not x is y). Yes, I've done that too. But that's not the bytecodes (at least not what I understand as bytecodes) that's the dis-asse

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Mark Lawrence
On 28/05/2013 00:32, Steven D'Aprano wrote: On 28/05/13 06:01, Jim Mooney wrote: Another question. I tried installing a package that back-compiles (in win 7), so I could see things that way, and got the error "Unable to find vcvarsall.bat" Shall we guess what package that is? I love guessing g

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread ALAN GAULD
I can't speak for Jim, but I have used the dis module in the past to >quickly check how python parsed an expression (e.g. not x is y). >Yes, I've done that too. But that's not the bytecodes (at least not what  I understand as bytecodes) that's the dis-assembly listing which is  usually far more use

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Steven D'Aprano
On 28/05/13 06:01, Jim Mooney wrote: I was looking at the bytecode doc page as a break from the Lutz book, since I like Assembler-type code due to its total non-ambiguity, but the page doesn't say much. Is there a doc somewhere that corresponds some of the bytecode to Python source? I thought rot

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Devin Jeanpierre
On Mon, May 27, 2013 at 7:20 PM, Alan Gauld wrote: > Can you give a use case of how you think you could use them? > There may be another way to do what you want. I can't speak for Jim, but I have used the dis module in the past to quickly check how python parsed an expression (e.g. not x is y).

Re: [Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread SM
Thank you, for the details. On Mon, May 27, 2013 at 10:13 AM, eryksun wrote: > On Mon, May 27, 2013 at 9:45 AM, Matthew Ngaha > wrote: > > On Mon, May 27, 2013 at 2:14 PM, SM wrote: > > > >>But then I also had to use self.fileDialog from within the function. Not > >> sure how I could avoid us

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Alan Gauld
On 27/05/13 21:21, Jim Mooney wrote: Oscar Benjamin What do you want these for? I've never needed to know what the interpreter's bytecodes are. I programmed A86 Assembler years ago, and just find the bytecode has a comfortable clarity as a learning tool, To me, the bytecodes are the litera

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Jim Mooney
Oscar Benjamin > What do you want these for? I've never needed to know what the > interpreter's bytecodes are. I programmed A86 Assembler years ago, and just find the bytecode has a comfortable clarity as a learning tool, at least for me. When an author vaguely tried to explain that a Name in Py

Re: [Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Oscar Benjamin
On 27 May 2013 21:01, Jim Mooney wrote: > > I was looking at the bytecode doc page as a break from the Lutz book, > since I like Assembler-type code due to its total non-ambiguity, but > the page doesn't say much. Is there a doc somewhere that corresponds > some of the bytecode to Python source? I

[Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Jim Mooney
I was looking at the bytecode doc page as a break from the Lutz book, since I like Assembler-type code due to its total non-ambiguity, but the page doesn't say much. Is there a doc somewhere that corresponds some of the bytecode to Python source? I thought rot_1, 2, 3, and 4 looked useful, but it w

Re: [Tutor] Buttons

2013-05-27 Thread Alan Gauld
On 27/05/13 15:17, Jack Little wrote: Is there a way to make buttons a little like a raw_input in the context when the user presses the button, the program performs a function? Yes, but its a lot more complicated than raw_input. See the GUI topic of my tutorial for examples. Also check out th

Re: [Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread eryksun
On Mon, May 27, 2013 at 9:45 AM, Matthew Ngaha wrote: > On Mon, May 27, 2013 at 2:14 PM, SM wrote: > >>But then I also had to use self.fileDialog from within the function. Not >> sure how I could avoid using fileDialog. >> > > No problem. to do it without the instance variable, you access its > m

[Tutor] Buttons

2013-05-27 Thread Jack Little
Is there a way to make buttons a little like a raw_input in the context when the user presses the button, the program performs a function?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailma

Re: [Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread SM
Yes, the following works. path = QtGui.QFileDialog.getOpenFileName() Thanks! On Mon, May 27, 2013 at 9:45 AM, Matthew Ngaha wrote: > On Mon, May 27, 2013 at 2:14 PM, SM wrote: > > >But then I also had to use self.fileDialog from within the function. Not > > sure how I could avoid using fileDi

Re: [Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread Matthew Ngaha
On Mon, May 27, 2013 at 2:14 PM, SM wrote: >But then I also had to use self.fileDialog from within the function. Not > sure how I could avoid using fileDialog. > > Thanks. No problem. to do it without the instance variable, you access its method directly. so replace: path = self.fileDialog.getO

Re: [Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread SM
Thanks! I defined a function, as you suggested, to call when the button was clicked. But then I also had to use self.fileDialog from within the function. Not sure how I could avoid using fileDialog. I also defined global variable (under the class) and assigned it to the filename, so I could access

[Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

2013-05-27 Thread Matthew Ngaha
Sorry for the forward, i forgot to reply to tutor On Mon, May 27, 2013 at 3:53 AM, Sunitha Misra wrote: > self.fileDialog = QtGui.QFileDialog() > > QtCore.QObject.connect(self.toolButton, > QtCore.SIGNAL(_fromUtf8("clicked()")), self.fileDialog.getOpenFileName) > i think the way youre doing it