In Python I can automatically create an unicode object by prepending an u
(as in u"test"
).
Is it possible to build something like that myself?
In Python I can automatically create an unicode object by prepending an u
(as in u"test"
).
Is it possible to build something like that myself?
All things are possible - but in this case, only by modifying the source code of the Python interpreter and recompiling.
A related question with the same answer: Can you add new statements to Python's syntax?
Yes you can.
All you need to do is type the following:
ur"\u<hex>"
For example, if you were to type
print ur"\u0186"
it would output the following character (given you are using a certain font)
҉
To print this, you could just simply type
print "҉"
but for this to be allowed, you must put the following line of code as the FIRST line of code
# -*- coding: utf-8 -*-
Yes, I know it has the # symbol, that is supposed to be there. Hope this helps! Have fun with unicoding! :)