in-place

Re-arranging numpy array in place

Re-arranging numpy array in place
I am trying to modify a numpy array "in-place". I am interested in re-arranging the array in-place (instead of return:ing a re-arranged version of the array).Here is an example code:from numpy import * def modar(arr): arr=arr[[1,0]] # comment &a

move from right side to odd positions and from left side to even in-place

move from right side to odd positions and from left side to even in-place
Given a non-empty array of items. You have to move all the items from the right side to odd positions (zero-based), and from the left side - to even positions, as follows:raw data: 0 2 4 6 8 10 12 14 1 3 5 7 9 11 13result: 0 1 2 3 4 5 6 7 8 9 10 11 1

Replace regex in a file, in-place, with Common Lisp

Replace regex in a file, in-place, with Common Lisp
I am trying to write the Common Lisp version of Python's regex search and replace, with in-place modification of files:import fileinput, re for line in fileinput.input(inplace=1, backup='.bak'): line = re.sub(r"foo", "bar", line, re.M)
What Others Are Reading