On May 26, 2007, at 8:19 AM, Pablo De Napoli wrote: > Hi, > > I see that sage has a method for computing the quotient and reminder > of the integer > division called "quo_rem" (in integer.pyx) > However, there exist a standard operator in python call divmod: in > sage divmod does > not work as one would expect. > > sage: ZZ(2).quo_rem(ZZ(3)) > (0, 2) > > sage: divmod(ZZ(2),zz(3)) > ---------------------------------------------------------------------- > ----- > <type 'exceptions.NameError'> Traceback (most recent > call last) > > /hdc1/pablo.hdc1/sage/sage/<ipython console> in <module>() > > <type 'exceptions.NameError'>: name 'zz' is not defined
The error is because you wrote zz(3) with lowercase z. In sage, one does not need to use ZZ as it is added to literal integers automatically by the sage preparser. > in standard iPython: > > In [1]: divmod(2,3) > Out[1]: (0, 2) > > Would it better to use the standard name divmod for this operator [by > defining a method __divmod__] (or other operators > already defined in python) when possible? I think this would be a good idea. I don't know if there's any reason we're not doing so yet... I think this is a good idea. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---
