Re: Python curses
On Tue 10 Jan 2023 at 11:13:55 (-0500), paulf@quillandmouse.com wrote:
> On Tue, 10 Jan 2023 09:31:26 -0600 > David Wright <deblis@lionunicorn.co.uk> wrote:
> > You keep mentioning "the docs" without saying which docs, so a
> > reference might be helpful.
>
> Sorry. I'm using the following (and related pages):
>
> https://docs.python.org/3/library/curses.html
>
> These appear to be the most authoritative.
Correct.
> > On Tue 10 Jan 2023 at 09:01:17 (-0500), paulf@quillandmouse.com wrote:
> > > On Tue, 10 Jan 2023 08:34:05 -0500 Greg Wooledge <greg@wooledge.org> wrote:
> > > > On Tue, Jan 10, 2023 at 08:24:11AM -0500, paulf@quillandmouse.com wrote:
> > > > > What you wrote triggered something. I'd been following the
> > > > > Python curses docs, which tell you to write, for example,
> > > > > "A_REVERSE".
No, they don't.
> > > > > And Python was throwing exceptions. But based on
> > > > > what you wrote, I substituted "curses.A_REVERSE", which works.
> > > > >
> > > > > Problem solved... for now.
> >
> > Exactly: just for now.
> >
> > > > I'm a Python novice, but I believe what you're seeing is the
> > > > difference between
> > >
> > > No, here's what happened. I was going along, and I used "A_REVERSE"
> > > in my code, according to the online docs. Exception, didn't
> > > recognize the name. That didn't make sense; this attribute is basic
> > > to curses.
Exactly, it's an attribute, as shown by the heading of the table
in which you found A_REVERSE. And that attribute is a part of
the curses module, and must be qualified with curses.A_REVERSE
unless you import A_REVERSE (or all, *) into your namespace.
What has misled you is that all the /tables/ in the python
documentation have just the last component's name in column one,
with its interpretation in column two. If you want to see why,
glance at a page like
file:///usr/share/doc/python3/html/library/collections.abc.html
for example. The first ABC item in the table is "Container",
but the running text below shows:
class collections.abc.Container
ABC for classes that provide the __contains__() method.
The table would be unmanageable if most of its width was taken
up with repetitions of:
class collections.abc.… … … …
class collections.abc.… … … …
class collections.abc.… … … …
class collections.abc.… … … …
class collections.abc.… … … …
class collections.abc.… … … …
Cheers,
David.
Reply to: