Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread Marc Tompkins
On Thu, Jan 8, 2009 at 3:45 PM, wesley chun wrote: > A tuple of exceptions works, just like what we did above, and more, > i.e., (IndexError, ValueError, TypeError, KeyError... > > Thank you, thank you, thank you! I'm sure it's been staring me in the face, but I never realized I could use a tupl

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread Alan Gauld
"culpritNr1" wrote Say I have this nice list of lists: LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], ['chrX', '161109992', '161109993', 'rs13484104', '63.60'], Now I want to cast the second and third "columns" from string to integer, like this LoL = [['

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread wesley chun
>> except: >>pass >> >> try not to code these 2 lines in anything that you do because it will >> come back to haunt you when something is not working right but you >> can't find any errors. that's because this code masks and throws away >> everything!! > > there are two potential error types: I

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread Marc Tompkins
On Thu, Jan 8, 2009 at 2:21 PM, wesley chun wrote: > except: >pass > > try not to code these 2 lines in anything that you do because it will > come back to haunt you when something is not working right but you > can't find any errors. that's because this code masks and throws away > everythin

Re: [Tutor] linked list with cycle structure

2009-01-08 Thread David Hláčik
Hi, well i am able to find a loop in a list using two iterators.One iterator runs "two times faster than the other", and if he encounters the first, it means that there is a loop. Example : 1,2,3,4,5,6,7,8,9,5 the algorithm would generate: start - 1,2 iteration 1- 2, 4 iteration 2- 3, 6 iteratio

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread wesley chun
>> LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], >>: >> Now I want to cast the second and third "columns" from string to integer, >> like this >> >> LoL = [['chrX', 160944034, 160944035, 'gnfX.145.788', '63.60'], >>: >> Is there any elegant way to do this? I ca

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread spir
Le Thu, 8 Jan 2009 11:51:01 -0800 (PST), culpritNr1 a écrit : > > Hi All, > > Say I have this nice list of lists: > > LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], > ['chrX', '161109992', '161109993', 'rs13484104', '63.60'], > ['chrX', '161414112

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread Marc Tompkins
On Thu, Jan 8, 2009 at 11:51 AM, culpritNr1 wrote: > > Hi All, > > Say I have this nice list of lists: > > LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], > ['chrX', '161109992', '161109993', 'rs13484104', '63.60'], > ['chrX', '161414112', '161414113',

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread spir
Le Thu, 8 Jan 2009 11:34:49 -0500, "Michael Langford" a écrit : > Here is your algorithm made more pythonic. Notice the use of default > parameters, doc strings, not abbreviated variable names, unix C style > capitolization (very subjective, but often the one found in python > libs), the avoidan

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
Thank you again. I now have enough to keep me happily busy for days. Robert Michael Langford wrote: I understand that each response is unique Robert and no caching is required to solve the problem at hand. However in a real program, the chance you're brute forcing just one password is small (us

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Michael Langford
I understand that each response is unique Robert and no caching is required to solve the problem at hand. However in a real program, the chance you're brute forcing just one password is small (usually you would brute force many); additionally, the question posted specifically asked that the trials

[Tutor] casting string to integer in a list of lists

2009-01-08 Thread culpritNr1
Hi All, Say I have this nice list of lists: LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], ['chrX', '161109992', '161109993', 'rs13484104', '63.60'], ['chrX', '161414112', '161414113', 'rs13484105', '63.60'], ['chrX', '161544071', '1615

Re: [Tutor] Functions and Mainloop()

2009-01-08 Thread John Fouhy
2009/1/9 Jonathan Balkind : > Hi tutor list, > I haven't been programming for long with Python, and I'm currently trying to > make a simple game using Tkinter. I was wondering whether it is possible to > submit a function to the mainloop so it will run every time the loop goes > around? I thought a

[Tutor] Functions and Mainloop()

2009-01-08 Thread Jonathan Balkind
Hi tutor list, I haven't been programming for long with Python, and I'm currently trying to make a simple game using Tkinter. I was wondering whether it is possible to submit a function to the mainloop so it will run every time the loop goes around? I thought about adding the function to the event

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
Richard Lovely wrote: 2009/1/8 Kent Johnson : This is a strange requirement. If you want to try all combinations of lowercase letters, the simplest way to do that is with nested loops. The loops will generate all combinations without repeating, so there is no need to save the use

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
Kent Johnson wrote: On Thu, Jan 8, 2009 at 10:49 AM, Robert Berman wrote: Hi, One of the challenges on the challenge you web page appropriately titled 'Brute force' reads as follows: "The password you have to guess is 'loner' . Try all combinations of lowercase letters until y

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
Michael, Thank you for your code and your commentary. The code tells me this is really an ongoing learning process; almost as convoluted as linguistics and certainly every bit as interesting. Your concept of brute force in this example is intriguing. It is as if I have five cogs spinning, 'a'

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Richard Lovely
2009/1/8 Kent Johnson : > > This is a strange requirement. If you want to try all combinations of > lowercase letters, the simplest way to do that is with nested loops. > The loops will generate all combinations without repeating, so there > is no need to save the used combinations. > or itertool

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Kent Johnson
On Thu, Jan 8, 2009 at 10:49 AM, Robert Berman wrote: > Hi, > > One of the challenges on the challenge you web page appropriately titled > 'Brute force' reads as follows: > > "The password you have to guess is 'loner' . Try all combinations of > lowercase letters until you guess it. Try not to lo

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Michael Langford
Here is your algorithm made more pythonic. Notice the use of default parameters, doc strings, not abbreviated variable names, unix C style capitolization (very subjective, but often the one found in python libs), the avoidance of control variables when possible, the use of ascii_lowercase instead

[Tutor] Thank you, Alan.

2009-01-08 Thread WM.
I felt such a monkey until Kent convinced me that the 'else' only appeared to be un-indented. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
Hi, One of the challenges on the challenge you web page appropriately titled 'Brute force' reads as follows: "The password you have to guess is 'loner' . Try all combinations of lowercase letters until you guess it. Try not to loop much for example, save all used combinations in an array so

Re: [Tutor] Chord player

2009-01-08 Thread Mr Gerard Kelly
Actually, I think I can minimize the clipping sound by setting the sample_rate to be one hundred times the value of the highest frequency in the chord. But it's still there for the notes underneath. Oh well, better than nothing! - Original Message - From: Mr Gerard Kelly Date: Thursday,

[Tutor] Chord player

2009-01-08 Thread Mr Gerard Kelly
I want to thank Emmanuel from the tutor mailing list for showing me a piece of code that let me do exactly what I wanted - making Python play a chord from a input of frequencies. I only needed to make a few adjustments. The code (below) uses Numeric. Emmanuel said that Numeric is out of date and s

Re: [Tutor] variable number of inputs

2009-01-08 Thread Alan Gauld
"wesley chun" wrote a very popular idiom you'll see in function signatures looks like this: def func(*args, **kwargs) this is the most flexible Python function definition because this function can accept *any* number and type of arguments you can give But the caveat: With power comes resp