# Revision history [back]

The current idiom is something like this:

n = 51
K = 720
C = EllipticCurve(Integers(n), [2, 49])
P = C([1,1])

try:
K*P
except ZeroDivisionError as err:
d = Integer(err.args[0].split()[2])
g = gcd(d,n)
print n, 'has divisor', g


You'll sometimes see "except ZeroDivisionError, e:" which is an older style. The args[0].split()[2] stuff is because the exception which is thrown has a string as the first argument of the args tuple:

sage: err.args
('Inverse of 34 does not exist (characteristic = 51 = 17*3)',)


so it's not so pretty to extract it in this case.

The relevant section of the Python tutorial covers it pretty well.

The current idiom is something like this:

n = 51
K = 720
C = EllipticCurve(Integers(n), [2, 49])
P = C([1,1])

try:
K*P
except ZeroDivisionError as err:
d = Integer(err.args[0].split()[2])
g = gcd(d,n)
print n, 'has divisor', g


You'll sometimes see "except ZeroDivisionError, e:" which is an older style. The args[0].split()[2] stuff is because the exception which is thrown has a string as the first argument of the args tuple:

sage: err.args
('Inverse of 34 does not exist (characteristic = 51 = 17*3)',)


so it's not so pretty to extract it in this case.

The relevant section of the Python tutorial covers it pretty well.