LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-01-2008, 11:08 PM   #1
donnied
Member
 
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
traene
Member
 
Registered: Jan 2005
Distribution: Archlinux, Debian, Centos
Posts: 222

Rep: Reputation: 35
I haven't tried that, but maybe the unicode package will help:
Code:
print unicode.name(g)
 
Old 02-03-2008, 11:31 PM   #3
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
Code:
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
donnied
Member
 
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
 
  


Reply

Tags
python, unicode, variables



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:46 AM.

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