Just pointed out an improvement to the code example.

This commit is contained in:
Raymond Hettinger 2003-01-25 20:30:02 +00:00
parent 45511b4a61
commit 9c13bfc40f
1 changed files with 1 additions and 1 deletions

View File

@ -86,7 +86,7 @@ Since booleans are a subclass of integers, the matrix would continue
to calculate normally, but it will not print as expected. The list
comprehension should be changed to read::
return [[i==j and 1 or 0 for i in range(m)] for j in range(m)]
return [[int(i==j) for i in range(m)] for j in range(m)]
There are similiar concerns when storing data to be used by other
applications which may expect a number instead of True or False.