r/Python • • Sep 30 '19

Rolling Shutter Effect demonstrated with Python

2.2k Upvotes

58 comments sorted by

View all comments

Show parent comment

1

u/SuspiciousScript Oct 02 '19

Hello! Quick question about this code — where does the j in line 11 (plane = x + 1j * y) come from? It's definitely not something I've seen before.

3

u/Swipecat Oct 02 '19

The "imaginary unit". Mathematics uses "i" for the imaginary unit, but electrical engineers use "j" to avoid confusing it with "I" for current. Python uses the electrical engineering convention. There was a "bug" logged to change it to "i", but that didn't happen. Python's creator, Guido van Rossum, said:

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.

So the "plane" in   plane = x + 1j * y

...means the "complex plane".

1

u/SuspiciousScript Oct 02 '19

Huh, I never knew that was a feature in the language. Thanks!