So, I’ve been programming in python and I’ve run into this really annoying issue. I wrote a small matrix library and started using it in another module (eg, import matrixlib). I’d find a bug, fix it and run the program again. Bug still there.
I’d throw in a few print statements to see what’s going on, but they wouldn’t print. I eventually figured out that my changes weren’t registering with python. So I started deleting .pyc files (precompiled python) but that didn’t help.
I eventually gave up and just started programming straight from the matrix lib file, but now that issue has come back. I threw in a print statement to figure out what was going on with a method, fixed the issue, and took it out. But it still prints. I even did a search for ‘print’ in a different text editor than IDLE, but found only not a single print statement in the code.
This isn’t really a code issue per say, I’ve probably mucked up my python install somehow. (This only happens on my windows box, not my linux box). If you want to see the code anyway, feel free. The hiesenbug-print statement is commented out in my code, yet still executes.
def det(self):
#Had better be a square matrix.
if self.colCount() != self.rowCount():
return None
#Are we a 1x1 matrix?
if self.colCount() == self.rowCount() == 1:
return self.a[0][0]
#Are we a 2x2 matrix?
if self.colCount() == self.rowCount() == 2:
return self.a[0][0]*self.a[1][1]-self.a[1][0]*self.a[0][1]
#Not a 2x2... so lets start recursing.
d = 0
for e in range(0,self.colCount()):
tmp = partition(self.a, 0, e)
if e%2 == 0:
d = d + self.a[0][e]*self.detRecursive(tmp)
else:
d = d - self.a[0][e]*self.detRecursive(tmp)
#print d
return d
def detRecursive(self, matrix):
m = Matrix()
m.setMatrix(matrix)
return m.det()
def partition(a, r, c):
out = []
for row in range(0, len(a)):
if r != row:
out.append([])
for col in range(0, len(a[0])):
if col != c:
out[-1].append(a[row][col])
return out
i think that when you have installed your package the first time you did:
rather than:
because when you do
setup.py installthe setup.py just copy the package files in the system path so every time you do a change in the package file you have to rerunsetup.py installin the other hand
setup.py developinstall your package in ‘development mode’ which mean that it just create a link (an eggs) to your “local” package files so every changes in the library “local” files is detected (it just a link)Hope this will help 🙂