[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python curses



* On 2023 09 Jan 22:05 -0600, paulf@quillandmouse.com wrote:
> Folks:

I'm not python curses expert, but is what I found.

> I'm trying to write some code in Python's curses module. I've run into
> common curses items like A_NORMAL which don't exist. When I do a
> print(curses.version), it shows "b 2.2". This tells me that the Debian
> (testing) version of python curses is version 2.2. The documentation
> for python curses at docs.python.org mentions versions up to 3.10.

Presumably you're running Bullseye as am I.  Here is what I show:

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> print(curses.version)
b'2.2'
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'curses']
>>> dir(curses)
[...(snip lots of stuff), 'A_NORMAL', (snip even more stuff)]

>>> curses.A_NORMAL
0
>>> curses.A_PROTECT
16777216
>>> curses.A_BOLD
2097152
>>> curses.A_COLOR
65280

Do you get similar values for those constants?

> Is it really possible that the latest version of Python in Debian
> testing is linked to (or however it works) the 2.2 version of Python
> curses?

Yes.  I'm not familiar at all with the versioning of such modules.
Perhaps the Python folks have decided to normalize the versions of
modules with the main interpreter version resulting in an apparent
version jump.

The curses module should be a rather old and stable module so I would
expect it to be fully functional and quite well debugged.

> If someone has insights here, I'd be grateful.

Looking at /usr/include/curses.h on Bullseye at line 1059 it can be seen
how ncurses defines A_NORMAL to be 0.

- Nate

-- 
"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."
Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

Attachment: signature.asc
Description: PGP signature


Reply to: