473,386 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Curses and Character Handling

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 '06 #1
3 1371

st************@gmail.com 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 '06 #2
Thank you very much.

Apr 9 '06 #3
Alle 10:46, domenica 09 aprile 2006, st************@gmail.com 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
Apr 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Alexander | last post by:
Hello; I am trying to determine all of the cell attributes active on a given cell of a curses window. I start by getting a value that contains the attribute and character at the specified...
3
by: Brian | last post by:
Hello; I'm writing a program with curses in python and having a bit of trouble understanding how to use unittest. So far, I have used testing successfully -- as long as the report goes to stdout...
0
by: Magnus Lie Hetland | last post by:
I'm playing around with curses, and have had some problems with that... For example, I can't make colours work in Python, although several other curses-based programs use colours on my box....
4
by: Peter | last post by:
Last November I posted a message asking for advice on using simple screen handling techniques under Windows. Since then I have been occupied with family / job /Christmas /living and trying to...
7
by: M.Senthil Kumar | last post by:
hai all, I need a help from you. I 'm working in a project using "curses.h" in Linux using 'C'. I have some doughts regarding menus and line. 1. I used to draw box in window using...
48
by: Daniele C. | last post by:
As soon as my sourceforge.net project gets approved, I am going to build a ncurses port to win32 bindable to sockets, e.g. allowing VT100/ANSI terminals and the creation of simple terminal servers...
7
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
5
by: 7stud | last post by:
I can't see to get any y, x coordinates to work with curses. Here is an example: import curses def my_program(screen): while True: ch = screen.getch() if ch == ord("q"): break
4
by: Jimmy | last post by:
hi, all I attempt to use the function inch() to get the character at the current position, and compare it with a particular character like : if screen.inch(x,y) == 'F' but this method doesn't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.