You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to python and the double underscore is a little bit confusing to me. I have implemented the addition method for two field elements as below : def add(self, other):
if self.prime != other.prime:
raise RuntimeError('cannot add fields of different primes')
num = (self.num + other.num) % self.prime
return self.class(num, self.prime)
but while executing print(a+b==c) I am getting the following error TypeError: unsupported operand type(s) for +: 'instance' and 'instance'
what is happening here? and how do i run the add method on two field elements?
PS: I am not sure if github issues are the right place to ask such doubts, but let me know if there is any other discussion forum where these types are being discussed.
Thank you.
The text was updated successfully, but these errors were encountered:
Ok it seems like it was my fault. importing the class again fixes the problem, and python is interpreting "add" as "+" command automatically. Which is cool and something i didn't know. Anyway this issue can be closed.
I am new to python and the double underscore is a little bit confusing to me. I have implemented the addition method for two field elements as below :
def add(self, other):
if self.prime != other.prime:
raise RuntimeError('cannot add fields of different primes')
num = (self.num + other.num) % self.prime
return self.class(num, self.prime)
but while executing print(a+b==c) I am getting the following error
TypeError: unsupported operand type(s) for +: 'instance' and 'instance'
what is happening here? and how do i run the add method on two field elements?
PS: I am not sure if github issues are the right place to ask such doubts, but let me know if there is any other discussion forum where these types are being discussed.
Thank you.
The text was updated successfully, but these errors were encountered: