News for hackers. Stuff that matters.
Re:Sorting in Python by thomasahle on Wednesday June 11, 2014 @03:06PM (#7879819)
"In Python exchange can be done in two simultaneous assignments"

Good, but then why does all your code say

    temp = alist[i]
    alist[i] = alist[j]
    alist[j] = temp
And not

    alist[i], alist[j] = alist[j], alist[i]
It's confusing when you are trying to understand an algorithm, and the descriptions don't match the code.

On the more general lines it seems like a quite pleasant book.

Re:Sorting in Python by bnmnetp on Wednesday June 11, 2014 @03:17PM (#7879888)
Good point. Although we do introduce the long way first.

The reason we don't use a,b = b,a in our code is that it isn't very portable to other languages. We wrote this book as a second semester textbook. So most students are not very good programmers and will be transitioning to something like Java or C++ in the next semester.

Further, for most of the sorting algorithms we have exercises where we suggest that users modify the code themselves to use simultaneous assignment.

Re:Sorting in Python by javafoo on Wednesday June 11, 2014 @04:07PM (#7880134)
Crawling your book, i stumble over several codes that use flags instead of "return" to exit, by example, you use two flags for searching on an ordered list.

These kind of codes are not great for beginners because they tend to think that setting the flag is equivalent to exiting which is as you know an illusion.

Re:Sorting in Python by zatkin on Thursday June 12, 2014 @11:24AM (#7883911)
If possible, what's the equivalent using bitwise operations?