J
Jeremy N
I am working with Python in Maya, and have run into a problem with a
variable changing its contents without being scripted to do so. The
various print() statements below were from my efforts to track down
where it was occurring. I left them in so that anyone running this
will more easily see what's happening.
On the line that reads 'dx = d1 / dx ; print("dx = %f" % dx)' there
is something happening to the variable that is being printed
repeatedly between the lines. The print statements prior to this
particular line print '...xlist[0][1] = 0.5' . However, on this
line, that variable is being updated to reflect a new value, when no
assignment to that variable has been made at that time.
This leads me to believe that the variables 'dx' and 'xlist[0][1]'
are inexplicably linked. I have no idea why. Please help me.
a=[5,0,3,4]
b=[8,3,0,10]
c=[2,4,10,0]
nlist = [a,b,c]
xlist = [[],[],[]]
for i in range(len(nlist)) :
relist = list(nlist)
relist.pop(i)
dlist = list(nlist)
dlist.pop(0) ; dlist.pop(i)
for j in range(len(relist)) :
d1 = float(nlist[0])
d2 = float(relist[j][0])
dx = float(dlist[j])
r1 = 1 - ( abs(d1-dx) / float(d2) )
if r1 == 0.0 :
r1 += (d1 < d2)
xlist.append(float(r1))
del d1, d2, dx, relist, dlist
ylist = list(xlist)
print(xlist)
print(ylist)
for i in range(len(xlist)) :
relist = list(xlist)
relist.pop(i)
for j in range(len(relist)) :
print( "!!!!!!!!!!!!!!! NEW LOOP AT ( %d:%d ) !!!!!!!!!!!!!!!" %
( i, j ) )
print("%s / (%s + %s)" % ( str(xlist[j]), str(xlist[j]),
str(relist[j][( (i!=0) * ((j>=i)+(i-1)) )]) ) )
d1 = float(xlist[j]) ; print("d1 = %f" % d1)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
d2 = relist[j][( (i!=0) * ((j>=i)+(i-1)) )] ; print("d2 = %f" % d2)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
dx = d1 + d2 ; print("dx = %f" % dx)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
dx = d1 / dx ; print("dx = %f" % dx)
ylist[j] = float(dx) ; #print(ylist[j])
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
print( "||| xlist[2][0] = %s" % str(xlist[2][0]) )
print( "...\nxlist = %s\n..." % str(xlist) )
print(xlist)
print(ylist)
variable changing its contents without being scripted to do so. The
various print() statements below were from my efforts to track down
where it was occurring. I left them in so that anyone running this
will more easily see what's happening.
On the line that reads 'dx = d1 / dx ; print("dx = %f" % dx)' there
is something happening to the variable that is being printed
repeatedly between the lines. The print statements prior to this
particular line print '...xlist[0][1] = 0.5' . However, on this
line, that variable is being updated to reflect a new value, when no
assignment to that variable has been made at that time.
This leads me to believe that the variables 'dx' and 'xlist[0][1]'
are inexplicably linked. I have no idea why. Please help me.
a=[5,0,3,4]
b=[8,3,0,10]
c=[2,4,10,0]
nlist = [a,b,c]
xlist = [[],[],[]]
for i in range(len(nlist)) :
relist = list(nlist)
relist.pop(i)
dlist = list(nlist)
dlist.pop(0) ; dlist.pop(i)
for j in range(len(relist)) :
d1 = float(nlist[0])
d2 = float(relist[j][0])
dx = float(dlist[j])
r1 = 1 - ( abs(d1-dx) / float(d2) )
if r1 == 0.0 :
r1 += (d1 < d2)
xlist.append(float(r1))
del d1, d2, dx, relist, dlist
ylist = list(xlist)
print(xlist)
print(ylist)
for i in range(len(xlist)) :
relist = list(xlist)
relist.pop(i)
for j in range(len(relist)) :
print( "!!!!!!!!!!!!!!! NEW LOOP AT ( %d:%d ) !!!!!!!!!!!!!!!" %
( i, j ) )
print("%s / (%s + %s)" % ( str(xlist[j]), str(xlist[j]),
str(relist[j][( (i!=0) * ((j>=i)+(i-1)) )]) ) )
d1 = float(xlist[j]) ; print("d1 = %f" % d1)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
d2 = relist[j][( (i!=0) * ((j>=i)+(i-1)) )] ; print("d2 = %f" % d2)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
dx = d1 + d2 ; print("dx = %f" % dx)
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
dx = d1 / dx ; print("dx = %f" % dx)
ylist[j] = float(dx) ; #print(ylist[j])
print( "...xlist[0][1] = %s" % str(xlist[0][1]) )
print( "||| xlist[2][0] = %s" % str(xlist[2][0]) )
print( "...\nxlist = %s\n..." % str(xlist) )
print(xlist)
print(ylist)