LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   python: using a variable to print unicode character (https://www.linuxquestions.org/questions/programming-9/python-using-a-variable-to-print-unicode-character-618096/)

donnied 02-01-2008 11:08 PM

python: using a variable to print unicode character
 
I'd like to do something like:
g = 0000
while g < ffff
g = g+0001
print u'\u\g'
The question is: (how) can I have python evaluate the variable g and print the corresponding unicode character?

traene 02-03-2008 01:06 PM

I haven't tried that, but maybe the unicode package will help:
Code:

print unicode.name(g)

angrybanana 02-03-2008 11:31 PM

Code:

start = '0000'
stop  = 'ffff'

for i in range(int(start, 16), int(stop, 16)):
    print unichr(i)


donnied 02-09-2008 02:51 AM

excellent suggestion
 
Thank you. That really simplified the code. I won't say what I had done before, but your response was similar to a shell script I had used to create the data files used to create individual classes. doh.

Now, I will work on two more aspects:
directing the output to a formatted window using glade
providing a way to select/import fonts


All times are GMT -5. The time now is 01:50 AM.