Hi, On Tue, Apr 8, 2008 at 6:50 PM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote: > Hello, > > > > Anand Balachandran Pillai wrote: > > While playing around with true & floor division in Py3k... > > > > Python 3.0a4+ (py3k:62126, Apr 3 2008, 16:28:40) > > [GCC 4.1.2 20070626 (Red Hat 4.1.2-13)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> x=2+0j > > >>> y=3+0j > > >>> x / y > > (0.66666666666666663+0j) > > >>> x//y > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > TypeError: can't take floor of complex number. > > >>> x.__floordiv__(y) > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > TypeError: can't take floor of complex number. > > >>> x.__divmod__(y) > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > TypeError: can't take floor or mod of complex number. > > > > In Python2.5, > > > > [EMAIL PROTECTED] py3k]$ python2.5 > > Python 2.5.1 (r251:54863, Sep 6 2007, 17:27:08) > > [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> x=2+0j > > >>> y=3+0j > > >>> x/y > > (0.66666666666666663+0j) > > >>> x//y > > __main__:1: DeprecationWarning: complex divmod(), // and % are deprecated > > 0j > > >>> x.__floordiv__(y) > > 0j > > >>> x.__divmod__(y) > > (0j, (2+0j)) > > > > Shouldn't Py3k also return 0j for floor division ? If it does not want to > do > > floor division/divmod for complex numbers, shouldn't the exception > > error be more descriptive ? Or is this the expected behavior ? > > Yes, the DeprecationWarning has turned into a real error. > This is the normal evolution of python 3.0.
Thanks for the clarification. > > Then, I find the message quite descriptive: > >>> divmod(x,y) > > TypeError: can't take floor or mod of complex number. > What message would you want in this case? The message "can't take floor..." is slightly confusing since it could mean the floor or mod cannot be taken in this context, instead of conveying the (correct) information that this operation is invalid in any context. A message like "can't convert complex to float" or "Invalid operation, can't perform floor or mod on complex number", would be more informative. > > -- > Amaury Forgeot d'Arc > Thanks -- -Anand _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com