Curses and Character Handling

S

stormandstress

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.
 
M

mensanator

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.
'a'



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

Thanks in advance.
 
F

Fulvio

Alle 10:46, domenica 09 aprile 2006, (e-mail address removed) ha scritto:
Does anyone know of a solution to this

I still learning python, but probably some documentation is the basis of
learning, rather than ask at the list.

I suggest to see at http://docs.python.org/ for actual and growing python
functions and/or builtins.

F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top