Friends,
I want to define a function that can populate an array by taking its name
(which is defined globally). I defined two empty arrays as follows and a
function that can populate the array.
REF_F1=np.array([])
REF_F2=np.array([])
# populating the given array
def ref(ln,REF_F1):
global REF_F1
REF_F1=np.zeros((ln,3),dtype='float32')
for i in range(ln):
for j in range(3):
REF_F1x[i,j]=resid[Index[i]].cent()[j]
ref(ln, REF_F2)
In this case, when i pass REF_F2 as argument, the fn. always populates
array REF_F1. I also tried something like the following
*def ref(ln,x=REF_F1)* and then calling as *ref(ln,x=REF_F2)*. The result
is the same. Could someone please give me hint on how pass global variables
as arguments.
Thanks,
Bala
--
C. Balasubramanian
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor