Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbab26a

Browse files
committed
curses HOWTO: fix some PEP8 and a code example to actually raise the exception it promises.
1 parent f632494 commit dbab26a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/howto/curses.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ importing the :func:`curses.wrapper` function and using it like this::
143143
stdscr.clear()
144144

145145
# This raises ZeroDivisionError when i == 10.
146-
for i in range(0, 10):
146+
for i in range(0, 11):
147147
v = i-10
148148
stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))
149149

@@ -177,8 +177,8 @@ smaller windows, in order to redraw or clear them separately. The
177177
:func:`~curses.newwin` function creates a new window of a given size,
178178
returning the new window object. ::
179179

180-
begin_x = 20 ; begin_y = 7
181-
height = 5 ; width = 40
180+
begin_x = 20; begin_y = 7
181+
height = 5; width = 40
182182
win = curses.newwin(height, width, begin_y, begin_x)
183183

184184
Note that the coordinate system used in curses is unusual.
@@ -227,7 +227,7 @@ displayed. ::
227227
# explained in the next section
228228
for y in range(0, 99):
229229
for x in range(0, 99):
230-
pad.addch(y,x, ord('a') + (x*x+y*y) % 26 )
230+
pad.addch(y,x, ord('a') + (x*x+y*y) % 26)
231231

232232
# Displays a section of the pad in the middle of the screen.
233233
# (0,0) : coordinate of upper-left corner of pad area to display.
@@ -389,7 +389,7 @@ again, such combinations are not guaranteed to work on all terminals.
389389

390390
An example, which displays a line of text using color pair 1::
391391

392-
stdscr.addstr( "Pretty text", curses.color_pair(1) )
392+
stdscr.addstr("Pretty text", curses.color_pair(1))
393393
stdscr.refresh()
394394

395395
As I said before, a color pair consists of a foreground and background color.
@@ -412,7 +412,7 @@ When you change a color pair, any text already displayed using that color pair
412412
will change to the new colors. You can also display new text in this color
413413
with::
414414

415-
stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1) )
415+
stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1))
416416

417417
Very fancy terminals can change the definitions of the actual colors to a given
418418
RGB value. This lets you change color 1, which is usually red, to purple or

0 commit comments

Comments
 (0)