Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I'm learning python. I'm at a point where I need to have the option to tell if a particular character is either A_BOLD, A_DIM or A_REVERSE and so forth So I could in the end change its attribute as needs be (using for instance window.chgat(attr)). 

In any case, I don't have a clue how to recover this data. 

As per the documentation:

window.inch([y, x])¶

Return the character at the given position in the window. The bottom 8 bits are the character proper, and upper bits are the attributes.

I comprehend that the data about the character attribute is fused inside the outcome from inch and actually, printing the character acquired showcases it with its attributes also. 

However, Im not familiar enough in PC address see how to utilize this. How would I get and decipher/interpret those upper bit?... How would it be a good idea for me to respond, say, to check if the character is imprinted in bold or not?

1 Answer

0 votes
by (26.4k points)

You can actually use bitwise operators (Example &)

attrs = window.inch([y, x])

ch = chr(attrs & 0xFF)

isbold = bool(attrs & curses.A_BOLD)

Want to learn python to get expertise in the concepts of python? Join python certification course and get certified

Related questions

0 votes
1 answer
0 votes
4 answers
0 votes
1 answer
asked Jan 5, 2021 in Python by laddulakshana (16.4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...