On Tuesday, July 1, 2014 2:08 AM, Chris Angelico
wrote:
On Tue, Jul 1, 2014 at 7:00 PM, Andrew Barnert
wrote: src = src.replace('∅', '_EMPTY_SET_LITERAL')
Note that this suffers from a flaw that my POC script also suffers from: it replaces this character *anywhere*, rather than only when it's being used as a symbol on its own. Even inside a literal string. It might be necessary to replace it back the other way afterward, somehow, but I'm not sure if that would work.
Yes, that's easy. Also, _EMPTY_SET_LITERAL_ itself could exist in your source (after all, it exists in my source fragment right above, right?), but that's easy too. See https://github.com/abarnert/emptyset for a slapped-together implementation that solves both those problems (except for bytes literals, but it explains how to do that). If it prints out "set() is the empty set ∅", then it worked; it successfully replaced the ∅ in your source with an empty set literal, and left the ∅ in your format string as ∅.