How did a zero width space get into my python code
-
I use NP++ for editing all kinds of files including my Jython scripts for JMRI. Somehow a zero width space got into my code. It has taken me weeks to find it. I only solved the problem by adding a space where the zero width space was and then deleted the added space. The zero width pace went away.
How does that zero width space get into the code?
Dave Sand of the JMRI helped me with the problem and sent me this once I had fixed it:
*The original problem is that you created lines 173 and 174 with a zero width space, unicode E2808B, before the left paren.
4D 61 73 74 E2 80 8B 28 70
M a s t . . . ( pA normal space, x20, is ok before the left paren, the unicode zero width space is not. Make sure that your programming editor is not getting creative.*
-
Notepad++ would not add such a character unless you jumped through some major hoops. My guess is that you copy/pasted from some website that put the U+200B (bytes 0xE2 0x80 0x8B) for web display purposes.
-
How did a zero width space get into my python code
Beats me, but Notepad++ didn’t do it.
Make sure that your programming editor is not getting creative
I think this is meant to imply again that Notepad++ did it. I assure you that it did not.
Peter’s theory about a paste-in of data from another source is a really good theory.
There’s a PythonScript HERE that you can set up if you want such characters to be very visible in the future. However, the mechanism used to make them very visible defeats the purpose of their usage (but that sounds like it would be very OK with you).