Re: [Python-Dev] return type of __complex__

2012年10月19日 09:43:18 -0700

On Fri, Oct 19, 2012 at 5:31 PM, Christian Heimes <[email protected]> wrote:
> In order to fix the bug the code in PyComplex_AsCComplex() must be
> altered to support float as return type from __complex__(). That's a
> major change.
Agreed that this doesn't seem appropriate for bugfix releases.
We might also want to consider having PyComplex_AsCComplex check for
__float__, again for consistency with the 'complex' constructor:
>>> class A(object):
... def __float__(self):
... return 42.0
...
>>> a = A()
>>> float(a)
42.0
>>> complex(a)
(42+0j)
Mark
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to