Anton Vredegoor anton at
Thu Jun 12 16:56:30 CEST 2003

Tom <llafba at> wrote:

>I compare all items in a list with another value. There are always 
>multiple matches. I need the list index of every match. But if I use 
>index(x) it only returns the first match in that list. There is probably 
>a similar command that does exactly what I want, but I can't find it.

Probably because there isn't such a command :-) It's a oneliner
though, in a recent enough Python:

def indices(L,x):  return[i for i,y in enumerate(L) if x==y]

>Talking about that: is there any good online help or something like 
>that? I have the Python Library Reference, but I find that rather 
>confusing and with very short explanations. I think they set it up the 
>wrong way, because you already have to know the command you are actually 
>looking for?! If  I want to do something, I want to know which command I 
>can use! So, is there any online help or something you can recommend?

In open source communities there is the possibility of discussing the
source code with the original authors (if they're not too busy making
money). Because of this it's possible to help develop the product one
is using and for the authors to get specific feedback about the way
their product is used. It easy to see that these two aspects must
necessarily be linked for maximum effectiveness. 

So for open source the community is all important. Interact with the
fora and search the archives for answers to your questions. If after
some reasonable effort no obvious answer is found, write a small as
possible a script demonstrating what you want to or can not
accomplish, and post it here under a concise and descriptive subject

You have done well :-) Generations of Python programmers after you
will thank you for this. (That is if the subject was not one that has
come up a thousand times, which I didn't check, but which seems


More information about the Python-list mailing list