<p dir="ltr">Hm. What's wrong with rejecting bad ideas?</p>
<div class="gmail_quote">On Jun 22, 2014 1:19 PM, "Terry Reedy" <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Problem: For years, various people have suggested that they would like to use syntactically significant unicode symbols in Python code. A prime example is using U+2205, EMPTY SET, ∅, instead of 'set()'. On the other hand, the conservative, overwhelmed core development group is not much interested and would rather do other things.<br>

<br>
Solution: Act instead of ask.<br>
<br>
One or more of the people who really want this could get themselves together and produce a working system. (If multiple people, ask for a new sig and mailing list).<br>
<br>
1. Ask core development to reserve '.pyu' for python with unicode symbolds. (If refused, chose something else.)<br>
<br>
2. Write pyu.py. It should first translate x.pyu to the equivalent x.py. If x.py exists, check the date (at with .py and .pyc). Optionally, but probably by default, run x.py.<br>
<br>
Translation requires two operations: masking comments and string literals from translation and translating the remainder. I personally would start by doing the two operations separately, with separately testable functions.<br>

<br>
def codechunk(unisymcode):<br>
  '''Yield code_or_not, code_chunk pairs for code with unicode symbols.<br>
<br>
  Chunks are comments or string literals (code_or_not == False),<br>
  and code that might have unicode symbols that need translation<br>
  'code_or_not' == True).<br>
  '''<br>
  <Simplified parser, possibly derived from tokenize.tokenize(),<br>
  which already knows how to recognize comments and strings.><br>
<br>
unisym = <dict mapping unicode ordinals to ascii replacements><br>
<br>
def unisym2ascii(unisymcode):<br>
  blocklist = []<br>
  for code, block in codeblocks(unisymcode):<br>
    if code:<br>
      block = block.translate(unisym)<br>
    blocklist.append(block)<br>
  return ''.join(blocklist)<br>
<br>
3. Upload pyu.py to PyPI, *along with instructions on the various ways to enter unicode symbols on various systems*. Announce and promote.<br>
<br>
<br>
On 6/22/2014 10:41 AM, Philipp A. wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
if people are too lazy to find a input method that works for them (Alt<br>
Gr, compose key, copy&paste), they should just continue to type ASCII,<br>
and leave the more elegant unicode variants for others.<br>
</blockquote>
<br>
Being snarky can be fun, but if I wrote and distributed pyu.py, I would want as many users as possible.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
∅ and λ seem like good ideas to me as un-redefinable empty<br>
set literal and shorter/more elegant lambda. And “…” for “Ellipsis”.<br>
<br>
there’s also ∀, ¬, ×, ∧,∨, ∩, ∪, ∈, ∉, ≠, ≡, ≤, and ≥, but i think those<br>
are a bit much:<br>
</blockquote>
<br>
I think the unisym dict should be inclusive and let people choose to use the symbols they want. I suspect I use ≤ and ≥ b sooner than λ. A mathematician that used most of those symbols, for a math audience, could still use the ascii tranlation for other audiences.<br>

<br>
On 6/22/2014 11:01 AM, MRAB wrote:<br>
> λ is a valid identifier in Python 3 because it's a letter.<br>
<br>
Overall, I see this as less of a problem than the possibility of rebinding builtin names. The program could have a 'translate_lambda' (default True) parameter. But I would be willing to say that if you use unicode symbols, then you cannot also use λ as an identifier. (If one did, the resulting .py would stop with SyntaxError where 'lambda' repladed identifier λ.)<br>

<br>
-- <br>
Terry Jan Reedy<br>
<br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<u></u>codeofconduct/</a></blockquote></div>