Numerical Python Question
Cypher7
member at dbforums.com
Wed Oct 16 13:45:20 EDT 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 num.uni-sb.de than astronomy is about telescopes.
> (Dijkstra)
> http://www.procoders.net/http://www.procoders.net
>
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
try
dest = greater(orig1[:n],orig2[:n]) + dest[n:]
--
Posted via http://dbforums.com
More information about the Python-list
mailing list