Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-01-2008, 11:08 PM   #1
Registered: Oct 2006
Distribution: Debian x64
Posts: 198

Rep: Reputation: 30
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?
Old 02-03-2008, 01:06 PM   #2
Registered: Jan 2005
Distribution: Archlinux, Debian, grml
Posts: 210

Rep: Reputation: 33
I haven't tried that, but maybe the unicode package will help:
Old 02-03-2008, 11:31 PM   #3
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
start = '0000'
stop  = 'ffff'

for i in range(int(start, 16), int(stop, 16)):
    print unichr(i)
Old 02-09-2008, 02:51 AM   #4
Registered: Oct 2006
Distribution: Debian x64
Posts: 198

Original Poster
Rep: Reputation: 30
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


python, unicode, variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode Character Check in Perl gjagadish Programming 2 08-21-2007 11:31 PM
[Bash] New line character in variable michael_hk Linux - Newbie 4 06-15-2006 02:13 PM
unicode & frensh character ! ik@z Linux - General 1 05-17-2006 12:07 AM
php unicode global variable jayakrishnan Programming 1 03-10-2006 04:19 PM
lp print- alt196 character paulmccs Programming 0 03-08-2002 09:40 AM

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration