Not really an issue, but was working through the examples and noticed this combination of implementation choices:
on __init__() we check that bothself.x and self.y are None
when returning, we only see if self.xorother.x are None
I was initially thinking I could break this by trying Point(None, y) or Point(x, None), but get an error as it skips the infinity point check and tries to validate that the point is on the curve:
TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int'
So, for more of a python best practice question, why do something like raising a value error if the point isn't on a curve but allow this edge case to fail via a math operator error? I presume not checking if the point is actually on the curve could fail later due to calculating the slope of a point not actually on the curve, for example, but we deal with it explicitly up front.
Anyway, since this repo exists, thought I'd document the feedback. Loving the book so far!
Not really an issue, but was working through the examples and noticed this combination of implementation choices:
__init__()
we check that bothself.x
andself.y
areNone
self.x
orother.x
areNone
I was initially thinking I could break this by trying
Point(None, y)
orPoint(x, None)
, but get an error as it skips the infinity point check and tries to validate that the point is on the curve:So, for more of a python best practice question, why do something like raising a value error if the point isn't on a curve but allow this edge case to fail via a math operator error? I presume not checking if the point is actually on the curve could fail later due to calculating the slope of a point not actually on the curve, for example, but we deal with it explicitly up front.
Anyway, since this repo exists, thought I'd document the feedback. Loving the book so far!