Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why show() is not working when we are using with print?

Why show() is not working when we are using with print?

I have written a program to find a matrix as a result.

When I have finished and was tring to polish the output, I ended up the situation to use,

print " The matrix is ", show(A)

The output is just

The matrix is

its not giving the matrix.

if I use show() without print function, its giving the matrix.

How to fix this issue??

Thanks for helping..

Workdone:

As William Stein has given in his answer, I have used,

sys.stdout.flush()

after print function. But it didnt help me.

I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.

A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
    for j in range(6):
        C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)

Why show() is not working when we are using with print?

Why show() is not working when we are using with print?

I have written a program to find a matrix as a result.

When I have finished and was tring to polish the output, I ended up the situation to use,

print " The matrix is ", show(A)

The output is just

The matrix is

its not giving the matrix.

if I use show() without print function, its giving the matrix.

How to fix this issue??

Thanks for helping..

Workdone:

As William Stein has given in his answer, I have used,

sys.stdout.flush()

after print function. But it didnt help me.

I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.

A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
    for j in range(6):
        C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)

Its working if use in the next box in the notebook. But not in the same box. I dont know why??

Why show() is not working when we are using with print?

Why show() is not working when we are using with print?

I have written a program to find a matrix as a result.

When I have finished and was tring to polish the output, I ended up the situation to use,

print " The matrix is ", show(A)

The output is just

The matrix is

its not giving the matrix.

if I use show() without print function, its giving the matrix.

How to fix this issue??

Thanks for helping..

Workdone:

As William Stein has given in his answer, I have used,

sys.stdout.flush()

after print function. But it didnt help me.

I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.

A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
    for j in range(6):
        C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)

Its working if use in the next box in the notebook. But not in the same box. I dont know why??

click to hide/show revision 4
retagged

Why show() is not working when we are using with print?

Why show() is not working when we are using with print?

I have written a program to find a matrix as a result.

When I have finished and was tring to polish the output, I ended up the situation to use,

print " The matrix is ", show(A)

The output is just

The matrix is

its not giving the matrix.

if I use show() without print function, its giving the matrix.

How to fix this issue??

Thanks for helping..

Workdone:

As William Stein has given in his answer, I have used,

sys.stdout.flush()

after print function. But it didnt help me.

I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.

A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
    for j in range(6):
        C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)
click to hide/show revision 5
retagged

Why show() is not working when we are using with print?

Why show() is not working when we are using with print?

I have written a program to find a matrix as a result.

When I have finished and was tring to polish the output, I ended up the situation to use,

print " The matrix is ", show(A)

The output is just

The matrix is

its not giving the matrix.

if I use show() without print function, its giving the matrix.

How to fix this issue??

Thanks for helping..

Workdone:

As William Stein has given in his answer, I have used,

sys.stdout.flush()

after print function. But it didnt help me.

I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.

A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
    for j in range(6):
        C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)