Bizarre arithmetic results

Mark Dickinson dickinsm at
Thu Feb 11 15:21:57 CET 2010

On Feb 11, 1:38 pm, Duncan Booth < at invalid.invalid> wrote:
> Tim Chase <python.l... at> wrote:
> > But perhaps Py3 changes evaluation, returning an complex number.
> Yes, the change is documented at
> If it is in any of the "What's new in Python x.xx" documents or in a PEP
> somewhere I haven't spotted it.

Not in the 'what's new' documents, as far as I can tell, but this
change was introduced as part of implementing PEP 3141.

Here's an extract from the PEP, describing the 'Complex' abstract base

class Complex(Number):
    """Complex defines the operations that work on the builtin complex

    In short, those are: conversion to complex, bool(), .real, .imag,
    +, -, *, /, **, abs(), .conjugate(), ==, and !=.

    If it is given heterogenous arguments, and doesn't have special
    knowledge about them, it should fall back to the builtin complex
    type as described below.

    <snip lots of other abstractmethods here>

    def __pow__(self, exponent):
        """a**b; should promote to float or complex when necessary."""
        raise NotImplementedError


More information about the Python-list mailing list