Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
On 12/08/2011 05:03 PM, Steven D'Aprano wrote: Robert Berman wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. You will need to explain what you mean by "the index of 'c'". Do you mean 0, because 'c' is in position 0 of the sub-list

Re: [Tutor] list.index() question

2011-12-08 Thread Joel Goldstick
On Thu, Dec 8, 2011 at 5:03 PM, Steven D'Aprano wrote: > Robert Berman wrote: > >> Hi, >> >> Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want >> to get the index of 'c'. >> > > You will need to explain what you mean by "the index of 'c'". > > Do you mean 0, because 'c' is

Re: [Tutor] list.index() question

2011-12-08 Thread Steven D'Aprano
Robert Berman wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. You will need to explain what you mean by "the index of 'c'". Do you mean 0, because 'c' is in position 0 of the sub-list ['c', 3]? Or do you mean 2, because 'c' is in

Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
On 12/08/2011 04:27 PM, bod...@googlemail.com wrote: That won't work because l1[0] is ['a', 1] What happens if you don't change the code? l1.index('c') Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Robert Berman Sender: tutor-bounces+bodsda=googlemail@py

Re: [Tutor] list.index() question

2011-12-08 Thread bodsda
That won't work because l1[0] is ['a', 1] What happens if you don't change the code? l1.index('c') Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Robert Berman Sender: tutor-bounces+bodsda=googlemail@python.org Date: Thu, 08 Dec 2011 16:13:32 To: tutor S

Re: [Tutor] list.index() question

2011-12-08 Thread Alex Hall
On 12/8/11, Robert Berman wrote: > Hi, > > Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want > to get the index of 'c'. A one dimensional list is extremely easy; val = > list.index(value). But how do I get it for a list similar to l1. I have > tried ind = l1[0].index('c') an

Re: [Tutor] list.index() question

2008-12-08 Thread Damon Timm
On Mon, Dec 8, 2008 at 7:55 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > index() searches for a specific matching item, it doesn't have any > wildcard ability. Ah ha! > There is actually an index: > http://docs.python.org/genindex.html Heh heh - and the info I was looking for is at: http://docs

Re: [Tutor] list.index() question

2008-12-08 Thread Kent Johnson
On Mon, Dec 8, 2008 at 7:05 PM, Damon Timm <[EMAIL PROTECTED]> wrote: > Hi again! > > (Now that everyone was so helpful the first time you'll never get rid of me!) That's fine, pretty soon you'll be answering other people's questions :-) > I had a question about using the index() function on a li

Re: [Tutor] list.index() question

2008-12-08 Thread Alan Gauld
"Damon Timm" <[EMAIL PROTECTED]> wrote walk the directory path, I want to see if a directory contains any files ending in a certain type ... if it does, I wanna do some stuff Check out the glob module. for dirpath, subFolders, files in os.walk(rootDir): try: i = files.index("*.f

Re: [Tutor] list.index() question

2008-12-08 Thread John Fouhy
On 09/12/2008, Damon Timm <[EMAIL PROTECTED]> wrote: > Basically: how do I make it match *.flac ? I couldn't find anything > on google (searching for "python index" just gets me a lot of indexes > of python docs - wink) Hi Damon, The fnmatch module will help here. It basically implements uni