The code for the line painter on the website currently says:
def mouseReleaseEvent(self, e):
self.last_x = None
self.last_y = None
In the book it is:
def mouseReleaseEvent(self, e):
self.last_x = e.x()
self.last_y = e.y()
I believe the book is correct.
In the code to draw using mouseMoveEvent the position using e.x() and x.y() to draw the point using the current mouse position did not work for me. I had to use drawPoint(e.pos()) and worked fine. Also, it worked without addint the .setMouseTracking(True) line.
Another possible way to get the mouse position through the event variable e is e.pos().x() and e.pos().y().