Python Forum
is there an unused character in Python? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: is there an unused character in Python? (/thread-38455.html)



is there an unused character in Python? - Skaperen - Oct-14-2022

is there an unused character in Python? i'm looking for a character i won't see outside of quotes that i can drop into my code for some source processing that will end up being removed in the code output of that processing. something that can be in the code but will never exist in a double form would be an alternative. obviously i can't use double / for this, or even double *. but, maybe double % could be used, for example.

any ideas? maybe a ??


RE: is there an unused character in Python? - wavic - Oct-22-2022

A dollar sign?


RE: is there an unused character in Python? - Skaperen - Oct-23-2022

(Oct-22-2022, 08:05 AM)wavic Wrote: A dollar sign?
that would be usable for my processing. thank you! are you 100% sure there is no use of this character in Python source syntax (not counting inside any string)?

i have in a few cases mistyped # as $ (adjacent key on a US qwerty keyboard) and have always gotten a syntax error for it. and no, this processing is not for fixing typos.


RE: is there an unused character in Python? - wavic - Oct-23-2022

It can exist in a string obviously but I am 99.999 sure that Python doesn't use it at all. For now. Except in regular expressions. Perhaps that backtick " ` " too. But as I can see it is a deprecated usage instead of __repl__ in Python 2 according to that: https://stackoverflow.com/questions/1673071/what-do-backticks-mean-to-the-python-interpreter-example-num

I look at my keyboard now for all symbols and I am unable to see any other sign that is not used in Python's syntax.

If you are the only one that is going to use that code you could bind a key combination to a non-ascii symbol and use it instead. Some greek letter or even an emoji.


RE: is there an unused character in Python? - Gribouillis - Oct-23-2022

(Oct-23-2022, 05:33 AM)wavic Wrote: I am unable to see any other sign that is not used in Python's syntax.
My keyboard has $ € ¨ … ° « » – ` that are not used in Python's syntax. Also innumerable other unicode characters are not used in Python's syntax, but they can appear in literal strings.


RE: is there an unused character in Python? - Skaperen - Oct-23-2022

i have been rethinking my development and early designs. Unicode certainly adds a lot of possibilities. a partial need if this idea is to be able t type this, manually. that would mean a limited scope of keyboards.


RE: is there an unused character in Python? - wavic - Oct-24-2022

Quote:that would mean a limited scope of keyboards.

Why don't you use dmenu, get from some source all characters you need, pipe them to dmenu and use it to copy one of them to the clipboard and paste it in your code.


RE: is there an unused character in Python? - Skaperen - Oct-24-2022

the limited scope of keyboards is for others to type something special. i personally have ways to get any of Unicode's 1114112 characters into my files, and even more than that.

i do like $ as most people know how to do that, as opposed to a grinning smiley face that does not appear on their keyboard.


RE: is there an unused character in Python? - Skaperen - Nov-09-2022

the $ would be typed by the coder along with some defined other stuff and end by a final $ to specify something to be done by processing the code. that stuff will be removed from the modified code. so, the output will have no $ unless the action specifies to do so (there will be a flag to repeat processing).