On 11/13/2021 4:35 PM, pt...@austin.rr.com wrote:
Iโ€™ve not been following the thread, but Steve Holden forwarded me the

To explore the extreme case, I wrote a pyparsing transformer to convert identifiers in a body of Python source to mixed font, equivalent to the original source after NFKC normalization. Here are hello.py, and a snippet from unittest/utils.py:

def ๐š‘๐“ฎ๐–‘๐’๐‘œ():

 ย ย ย  try:

๐”ฅe๐—…๐•๐š˜๏ธด = "Hello"

๐•จ๐”ฌr๐“ตแตˆ๏นŽ = "World"

 ย ย ย ย ย ย ย  แต–๐–—๐ข๐˜ฏ๐“ฝ(f"{๐—ต๏ฝ…๐“ต๐”ฉยบ_}, {๐–œโ‚’๐’“lโ…†๏ธด}!")

 ย ย ย  except ๐“ฃ๐•ชแต–๏ฝ…๐–ค๐—ฟแตฃ๐–”๐š› as โ…‡๐—‘c:

๐’‘rโ„นโ‚™โ‚œ("failed: {}".๐•—๐—ผสณแตยช๏ฝ”(แต‰๐ฑ๐“ฌ))

if _๏ธดโฟ๐“ช๐‘š๐•–__ == "__main__":

๐’‰eโ„“หก๐—ˆ()

# snippet from unittest/util.py

_๐“Ÿโ…ฌ๐– ๐™ฒ๐—˜โ„‹๐’ชLแดฐ๐‘ฌ๐•ฝ๏น๐•ท๐”ผ๐—ก = 12

def _๐”ฐสฐ๐“ธสณ๐•ฅ๐™š๐‘›(๐”ฐ, p๐‘Ÿ๐”ข๏ฌ๐–๐•๐šŽ๐‘›, ๏ฝ“แตค๐‘“๐—ณ๐—‚๐‘ฅ๐—นโ‚‘๐š—):

 ย ย ย  หข๐—ธ๏ฝ‰๐—ฝ = ๐ฅ๏ฝ…๐˜ฏ(๐–˜) - ๏ฝr๐šŽ๐–‹๐ขx๐—…แต‰๐“ท - ๐’”๐™ช๏ฌ€๏ฝ‰๐˜…๐—น๐™šโ‚™

 ย ย ย  if s๏ฝ‹i๐˜ฑ > _๐๐—Ÿ๐– ๐˜Š๐™ดH๐•บ๏ผฌ๐•ฏ๐™€๐˜™๏นL๐”ˆ๐’ฉ:

๐˜ด = '%s[%d chars]%s' % (๐™จ[:๐˜ฑ๐ซ๐•–๐‘“๐•š๏ฝ˜โ„“๐’†๐•Ÿ], โ‚›๐š”๐’Šp, ๐“ผ[๐“๐’†๐–“(๐šœ) - ๐™จ๐šž๐’‡๏ฌx๐™กแต‰๐˜ฏ:])

 ย ย ย  return โ‚›

You should able to paste these into your local UTF-8-aware editor or IDE and execute them as-is.

Wow. After pasting the util.py snippet into current IDLE, which on my Windows machine* displays the complete text:

>>> dir()
['_PLACEHOLDER_LEN', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_shorten']
>>> _shorten('abc', 1, 1)
'abc'
>>> _shorten('abcdefghijklmnopqrw', 2, 2)
'ab[15 chars]rw'

* Does not at all work in CommandPrompt, even after supposedly changing to a utf-8 codepage with 'chcp 65000'.

--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/NSGBCZQ2R6G2HGPAID4ZI35YCRMF7ERC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to