Python Forum

Full Version: there is no str.isspecial()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
there is no str.isspecial() method that i can find. is there some short alternative?
>>> import string
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
i was looking for it to see what they claimed to be special characters in python3 to see if it included any new unicode ones.
Are unicode characters "special"?  They probably shouldn't be.
Sͤ̑͂̽ͯ҉̩̭o̮̍ͨͬ̒̍͂m͖̤ͬͧͬe͉̹̫̓ͣͦ̋ţ̝̮̱̟̤ͣ̉̾̏į̊̍̂̋ͧm̫̜̱ẹ͈ͩ̀ͫ͒̔̈̂͢s̩̺̯͇̱ͯ̀̈̃ ̝͉̊̎̀y̛̩̽̐ͮ͑͐̃o͉̜u̱̫̲̫̩͕ͤͮͩ͑͂͞ͅ ̲͔ͪ͂̇͒͢h̩̜͑͂ͩ̎͊a̭̲ͤͩ̅̉͋͂̿ve̳͎̲̤͒ͫ̔̈̊̎ͅͅ ̭̘̜t̗̦̝͙̘̮̮ȟ͏͇̥͓͓̪̫ị̲͉͓͎ͮ̌͌͛͐ͩͮ͟s̴͖̳̺͐̒ͪͫ͋̓̉ ̷̞̜͖͖̼̻̃̍sͤtͯͤ̍͗̔͂͟r̘ͩ̌̌̅̿̽ả̱͚̬͓̭̰͋̅n̥̱̹̤̩͓ͩͣ̔ͨ̐̾g̸͖͓̯̙̭ͮ̚e̹̩͍̻̽ͅ ̶͉̖̞̔̾̐̎s̷̮͚ͬ̉́ͪͬ̈́p̣̦̃̐̇̓ͫ͂ę͇̞c̫̿͞i̖͌͌a͆̒̓ͮ͋̎̚͘l̡ͯͪ̎ͭ ̫̣̱̰̭̹č̿ͮ̓̈҉͓̖̻̥ȟ̨̬̠̗͚̈́̐̽̃͊͆ạ̴̰͍͌̾̽̎r̰̦̈̽ͥ͌̄͟a̦̪͙̻̹̩͞ͅc̈̏̚t͙̹̳̣ͮͬ̀e̝̮̩̗̪ͩ̇ͣ̉̄͆ͅr̩͌̌͊ͦs̥̳̿̈ͪ ͕̠̗͈̯ͮ̊̑̀̅f̠̠͔̟̘ͮ̑ͧ͟ṟ͍̮̤̙̰̮̊ŏ̗̤̲͋m̟̬̭͞ ̳̠̲̺͈̖ͣ̍͒o̺̓ͫ̚t̗͕̮̼̥ͧ͝ͅh̰̟͕͋̆̚͘e͔͔͙̣̳̱͇͌ͥͪ̒̇̑͝r̨͕̫ ̺̙͔ͫ̚l͓͇͔̼̲̓̓̓ͧ̚͜a̧̻̹̳͕͎͈͓ͭ̒ͣ͌ṅ͓̣͢ͅg̩̻̥̖̯̟u̜͕͉ͅa͈̻̘̪̭̙̲͛̈̾͛͘g̡̭͎̯ͬ̋ͪ̂́e͉͢s̞̺͋̈̾̓̓ͯ̈́.̶ͣ T͖̤̳̟ͯ͒̇ͯô̧͓͙̂̆ͪ͒ ̪͚͕͕̗͋f͈̬͓̓ͬͬ̈̚i̡͖̹̤͍̯̙͗̆͌̇̿̿̑l̸̥͎͉͔t͙͍̳̟͎͔ê̷̹̱̘̥̫͚̱r̗̠͛̆̓͟ ̪̩̺t͚̙̾̓̌͑̾hͣ͌̾è̞̮̔͆̈͑̚m͛̋ͦ͋̍̊ͭ҉͖̰ ̺̙͓ͬ̓͆ó͖̦͉͉͈͖u̞ṭ̳̦͙̜͆̓͢,͎̠̤͛ ͓͉̘̔̄̕ĭ͉̪͖̱͇͢s̒̌̂̔̾ͯ҉̗ ͉̘͎̃ͥ̊͒̃͜ͅn̬̗͎ͯ̈̃̂̋̀̄ȍ̟͚ͮ͐̆ͫt̤̻̩̙̪̤̋̉ͬͦ̌̓ ͨ͆͊ͬ̉ͧͤe̝̣̬̖̞̬a͍ͭͨ͋̓̄͑̀s͍͌̅̌̈̚yͬ͂.

You've also some special groups like emoticons and modifiers which have been applied on the text above @http://www.eeemo.net/
there are many unicode characters above 128 that don't fit under alphabet or numeric.
Don't forget multiple byte codes, utf-16le, utf-32 etc
Are you concerned what Python considers a special character, or what unicode (specifically utf-8) considers special?
(Oct-05-2017, 12:44 AM)sparkz_alot Wrote: [ -> ]Are you concerned what Python considers a special character, or what unicode (specifically utf-8) considers special?
what Python considers a special character.  if they just let it be up to unicode then, fine.  i wish they would, at least, have proper tests for them, as a convenience.  if they provide one class, then IMHO they should provide all classes, so there isn't a mix of sources.
(Oct-05-2017, 12:37 AM)Larz60+ Wrote: [ -> ]Don't forget multiple byte codes, utf-16le, utf-32 etc
i didn't forget they exist.

does python3 use them for string types?  the bytes types are apparently 8-bit and thus utf-8.  the string type has to be using something or have some means that lets it abstract a wide range of numerical values.  i wrote this code that lets users work with these values numerically at the command line.  it takes a numeric value for one character per argument and outputs the utf-8 sequence.  i wrote it so i could output specific unicode in shell scripts (i can already do this in python).  it includes a function named intx() that accepts numeric values in many base prefixes (like '0y' for base 32, ':' for base 36, '0t' for base 3, '0q' for base 4) that is used to encode digits from each argument.  try this command to test it, if you have Linux.
python3 utf8.py 67 111 112 121 114 105 103 104 116 32 169 32 0x4c 0x61 :36 :3e 43 54 48 10
Pages: 1 2