See - http://www.programiz.com/python-programming/operator-overloading
the binary operators you can overload are +,-,*,|,^,&,<,>,<<, and >> (I may have forgotten one or two operators). The link shows how to overload and operator. Because of python's fixed operator precedence using parenthesis in expressions with your overloaded operators is essential to enforce the sequence of operation expression that you wish to occur. On Thu, Jun 2, 2016 at 5:06 AM, meInvent bbird <[email protected]> wrote: > beside traditional addition and multiply, > > i had extra 5 operator for a new algebra called AA > > because i am using logic 0,1,2 - 3 valued more than binary loic 0,1 only 2 > valued > > so i call the operation when deal with 2 are AA algebra > > you can assume one of operation is > def op3(a, b) > return a*b+1 > > op3(2,3) = 7 > > op3(2*aa, 3*aa) = 7*aa > > On Saturday, May 28, 2016 at 5:20:06 AM UTC+8, brombo wrote: >> >> Be more specific. What are you multiplying? What is the output. If you >> define a class for your operands you can overload *. >> >> On Fri, May 27, 2016 at 4:15 AM, meInvent bbird <[email protected]> >> wrote: >> >>> if i define a new custom multiply operator and would like to add to >>> existing algebra system in python >>> >>> how can i extend this function? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sympy" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/sympy. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sympy/e4678ef9-a787-4a05-aa10-78d60a65ebba%40googlegroups.com >>> <https://groups.google.com/d/msgid/sympy/e4678ef9-a787-4a05-aa10-78d60a65ebba%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/bd98161a-ee61-40b9-abce-5be4d4a95ede%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/bd98161a-ee61-40b9-abce-5be4d4a95ede%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CALOxT-n%3DWunahnX%3DN2oBO%2BUvZ7YodhUjhVWGcWN7sV6bTWR11A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
