really silly nit: why 3+5j instead of 3+5i?

Lloyd Zusman ljz at asfast.com
Sun May 14 10:08:33 EDT 2000


jimn at minusen.force9.co.uk writes:

> Lloyd Zusman <ljz at asfast.com> wrote:
> : "Andrew Dalke" <dalke at acm.org> writes:
> 
> [snip]
> : Clearly, there are two widely used representations of the square root
> : of -1: "i" and "j".  Forgive me if this question has been answered and
> : beaten to death in one or more earlier discussions, but is there any
> : reason why Python couldn't use both "i" and "j", as well?  Given that
> : things such as "1 + 3i" are currently illegal in Python, I don't
> : believe that any legacy code could possibly break if in a future
> : Python release, any one of 4 values ("j", "J", "i", and "I") could be
> : appended to a number to cause it to be treated as imaginary, instead
> : of just the two values we have today.
> 
> As I see it, the problem would come when converting a complex number
> to a string - which representation should it use? Is it not preferable 
> to use the same representation for display as is used for literals?

But even now, there are two choices: "j" and "J".  When converting the
number to a string, "j" is always used, irrespective of whether "J" was
used within the original complex literal.  This could still be the
case in the hypothetical future if "i" and "I" could also be used for
the numeric literals.


> Just my 2p worth.
> 
> Jim

-- 
 Lloyd Zusman
 ljz at asfast.com



More information about the Python-list mailing list