Curses and Character Handling

Discussion in 'Python' started by stormandstress@gmail.com, Apr 9, 2006.

  1. Guest

    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.
    , Apr 9, 2006
    #1
    1. Advertising

  2. Guest

    wrote:
    > 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.


    >>> chr(97)

    'a'


    >
    > If there's any other information you need in relation to this problem,
    > I'll post it, of course.
    >
    > Thanks in advance.
    , Apr 9, 2006
    #2
    1. Advertising

  3. Guest

    Thank you very much.
    , Apr 9, 2006
    #3
  4. Fulvio Guest

    Alle 10:46, domenica 09 aprile 2006, 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
    Fulvio, Apr 9, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jean-Paul Calderone
    Replies:
    2
    Views:
    423
    Joel Hedlund
    Feb 9, 2006
  2. John Hunter

    curses event handling

    John Hunter, Jun 7, 2006, in forum: Python
    Replies:
    0
    Views:
    266
    John Hunter
    Jun 7, 2006
  3. Replies:
    3
    Views:
    488
    James Kanze
    Nov 18, 2007
  4. George2
    Replies:
    2
    Views:
    367
    James Kanze
    Jan 25, 2008
  5. Replies:
    4
    Views:
    309
Loading...

Share This Page