Curses and Character Handling

stormandstress at gmail.com stormandstress at gmail.com
Sat Apr 8 22:46:18 EDT 2006


Hi.

I'm writing a program that is dependent on the curses library and
functions for python, and I'm a little puzzled by the way characters
are handled. The basics of the program are that a character is taken
from input and put into a certain position within a list (There's more
to it than that, but I think it's irrelevant). The problem is, when a
character is taken via the <window>.getch() function, what comes back
is an int corresponding to it's value ('a' = 97, 'b'=98, etc.). Now,
what I need to store is the character representation of this function -
it's not enough to simply have the 97/98 in the list, I need the 'a',
'b', etc.

Does anyone know of a solution to this, ideally in the form of a
built-in function that takes these numbers and returns the proper
character value? Obviously, str(<value>) doesn't work, as it just
returns '<value>'. I've read as many docs as I could lay my hands down,
and while the ord() function is useful for going the other way
(character to int), I need the reverse.

If there's any other information you need in relation to this problem,
I'll post it, of course.

Thanks in advance.




More information about the Python-list mailing list