where function

drochom drochom at googlemail.com
Sun Mar 18 18:51:36 EDT 2007


On 18 Mar, 15:19, vorticitywo... at gmail.com wrote:
> Is there a function in Python analogous to the "where" function in
> IDL?
>
> x=[0,1,2,3,4,2,8,9]
> print where(x=2)
>
> output:
> [2,5]

You can try this:

print filter( lambda x: a[x]==2, range(len(a)))

However it's not the best solution...




More information about the Python-list mailing list