Numerical Python Question

Cypher7 member at
Wed Oct 16 19:45:20 CEST 2002

Originally posted by Uwe Schmitt 
> Hi,
> I tried (similar to MatLab):
>    dest[:n] = greater( orig1[:n], orig2[:n])
> which does not work, the assignment with a sliced array
> on the left side seams not to be implemented.
> Is there any fast workaround ?
> Greetings, Uwe.
> --
> Dr. rer. nat. Uwe Schmitt      Computer science is no more about
>     Computers,
>     uwe.schmitt at      than astronomy is about telescopes.
>     (Dijkstra)

try slicing it on the right

>>>dest = "This is a string"
>>>dest = dest[:5] + "isn't a string?!  Wait yes it is"
>>> dest
"This isn't a string?!  Wait yes it is"

This should work with anything that you need to slice.

The above example takes the first 5 characters from dest and adds the
string "isn't a string?!  Wait yes it is""

Your example seems to assign the greater of orig1[:n] and orig2[:n] to
the first n posisions in dest

dest = greater(orig1[:n],orig2[:n]) + dest[n:]

Posted via

More information about the Python-list mailing list