[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
[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
a =
[0,1,2,3,4,2,8,9]
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
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:
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