Re: where function

2007-03-18 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: >> [...fine solutions to the problem as asked...] > Thank you both, a little more cumbersome than I expected, but it does > the job! Thanks! The obvious simple near-equivalent is: data = range(33,99) print data.ind

Re: where function

2007-03-18 Thread Steven Bethard
[EMAIL PROTECTED] 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] If you're doing a lot of this kind of thing, you probably want to use numpy:: >>> import numpy >>> x = numpy.array([0, 1

Re: where function

2007-03-18 Thread Shane Geiger
a = [0,1,2,3,4,2,8,9]

Re: where function

2007-03-18 Thread vorticitywolfe
On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: > vorticitywo: > > > Is there a function in Python analogous to the "where" function in > > IDL? > > Python gives very elastic syntax, you can simply do: > > data = [0,1,2,3,4,2,8,9] > print [pos for pos, el in enumerate(data) if el==2] > > Bye, > bearo

Re: where function

2007-03-18 Thread drochom
On 18 Mar, 15:19, [EMAIL PROTECTED] 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... -- http:

Re: where function

2007-03-18 Thread bearophileHUGS
vorticitywo: > Is there a function in Python analogous to the "where" function in > IDL? Python gives very elastic syntax, you can simply do: data = [0,1,2,3,4,2,8,9] print [pos for pos, el in enumerate(data) if el==2] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list