You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2011-11-21.19:26:59.297>created_at=<Date2010-11-28.15:19:14.854>labels= ['interpreter-core', 'type-feature']
title="Change 'j' for imaginary unit into an 'i'"updated_at=<Date2011-11-21.20:12:36.555>user='https://bugs.python.org/Retro'
In Python, the letter 'j' denotes the imaginary unit. It would be great if we would follow mathematics in this regard and let the imaginary unit be denoted with an 'i'.
Just to add my own thoughts: 'j' for *a* (not *the* </pedantry>) square root of -1 has, as Michael points out, a history of use in engineering (particularly electrical engineering) and physics. Personally, I would have preferred 'i' to 'j' here, but changing it now would cause (IMO) gratuitous breakage. It really doesn't seem a big enough issue to be worth making a fuss about.
While this thread was amusing to read, *changing* Python from the engineering notation to mathematical notation for imaginary numbers is not going to happen. 'i' has ambiguity problems relative to '1' and 'l' in too many fonts - 'j', on the other hand, almost always uses a visually distinct glyph. And whether 'i' or 'j' seems more natural to you will depend on whether or not you have an electrical engineering background (as noted earlier in the thread, 'i' refers to current in electrical engineering).
If you care about the precise formatting of a complex number, write your own formatting function rather than relying on the exact format produced by "repr(num)".
Having an alternate constructor for complex objects that was more forgiving about 'i' vs 'j' also doesn't offer a huge benefit over the simple "x = complex(arg.replace('i', 'j')".
So while I have some sympathy for mathematicians that are frustrated by having to train their fingers to hit 'j' instead of 'i', that's not a good enough reason to change the language syntax or the behaviour of the complex() builtin. (See also http://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html)
It's stupid that the imaginary unit in Python is denoted by a "j" just for ambiguity reasons that "i" can be mistaken with a "1" or an "l". It's true that "1" and "l" can look the same in some fonts, but that is *certainly not true* for the small letter "i".
This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.
Activity
Retro commentedon Nov 28, 2010
In Python, the letter 'j' denotes the imaginary unit. It would be great if we would follow mathematics in this regard and let the imaginary unit be denoted with an 'i'.
voidspace commentedon Nov 28, 2010
We follow engineering which uses j.
(I was about to close this as wontfix but Antoine is particularly keen that Mark deals with this issue...)
mdickinson commentedon Nov 28, 2010
Glad to oblige. :-)
mdickinson commentedon Nov 28, 2010
Just to add my own thoughts: 'j' for *a* (not *the* </pedantry>) square root of -1 has, as Michael points out, a history of use in engineering (particularly electrical engineering) and physics. Personally, I would have preferred 'i' to 'j' here, but changing it now would cause (IMO) gratuitous breakage. It really doesn't seem a big enough issue to be worth making a fuss about.
Retro commentedon Nov 28, 2010
"The Python programming language also uses j to denote the imaginary unit.
MATLAB associates both i and j with the imaginary unit."
-Wikipedia<http://en.wikipedia.org/wiki/Imaginary_unit#Alternative_notations\>
It would be a welcome feature in Python if the programming language would,
like MATLAB, associate both i and j with the imaginary unit.
abalkin commentedon Nov 28, 2010
Why not allow complex('1i')?
(Tongue in cheek: I am really looking for arguments against lax parsing in number builtins. See bpo-10557.)
mdickinson commentedon Nov 28, 2010
I suggest taking this to the python-ideas mailing list. A working patch might increase the idea's chances.
mdickinson commentedon Nov 28, 2010
Indeed, if 4i were permitted as an imaginary literal, I'd expect to allow complex('3 + 4i') as well.
(And possible just plain complex('i') too, since complex('j') is currently allowed. Grr.)
abalkin commentedon Nov 28, 2010
On Sun, Nov 28, 2010 at 3:58 PM, Mark Dickinson <report@bugs.python.org> wrote:
..
And with spaces surrounding '+' too.
Retro commentedon Nov 28, 2010
It would be great if the feature of having both j and i would exist in the
interpreter core, as well as the built-in function complex() to accept i.
pitrou commentedon Nov 28, 2010
There should be an environment variable to make the symbol settable.
$ PYTHONIMAGINARYSYMBOL=i python -c "import cmath; print(cmath.sqrt(-1))" 1i42 remaining items
Retro commentedon Nov 20, 2011
What's up with that now? Any interests in changing the imaginary unit from "j" to "i" ?
Retro commentedon Nov 20, 2011
Come on, let's do this.
ncoghlan commentedon Nov 20, 2011
While this thread was amusing to read, *changing* Python from the engineering notation to mathematical notation for imaginary numbers is not going to happen. 'i' has ambiguity problems relative to '1' and 'l' in too many fonts - 'j', on the other hand, almost always uses a visually distinct glyph. And whether 'i' or 'j' seems more natural to you will depend on whether or not you have an electrical engineering background (as noted earlier in the thread, 'i' refers to current in electrical engineering).
If you care about the precise formatting of a complex number, write your own formatting function rather than relying on the exact format produced by "repr(num)".
Having an alternate constructor for complex objects that was more forgiving about 'i' vs 'j' also doesn't offer a huge benefit over the simple "x = complex(arg.replace('i', 'j')".
So while I have some sympathy for mathematicians that are frustrated by having to train their fingers to hit 'j' instead of 'i', that's not a good enough reason to change the language syntax or the behaviour of the complex() builtin. (See also http://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html)
Retro commentedon Nov 21, 2011
It's stupid that the imaginary unit in Python is denoted by a "j" just for ambiguity reasons that "i" can be mistaken with a "1" or an "l". It's true that "1" and "l" can look the same in some fonts, but that is *certainly not true* for the small letter "i".
Just fix the "j" into an "i" already.
Retro commentedon Nov 21, 2011
Please fix this in Python 3.3 and don't forget to fix the complex() function/method as well.
briancurtin commentedon Nov 21, 2011
Please stop re-opening this thread. The reasons it will not be fixed have been laid out.
ericsnowcurrently commentedon Nov 21, 2011
@brian.curtin: +1
@retro: as noted in bpo-10621, please take this to python-ideas@python.org
gvanrossum commentedon Nov 21, 2011
This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.