Ticket #20584: 0002-Use-the-range-function-instead-of-xrange.patch

File 0002-Use-the-range-function-instead-of-xrange.patch, 1.3 KB (added by cypherpunks, 3 years ago)
  • docs/_static/example/event_listening.py

    From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
    From: cypherpunks <cypherpunks@torproject.org>
    Date: Fri, 4 Nov 2016 10:51:49 +0000
    Subject: [PATCH 2/4] Use the range function instead of xrange
    
    The xrange function no longer exists in Python 3 [0].
    
    [0] https://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists
    ---
     docs/_static/example/event_listening.py | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/docs/_static/example/event_listening.py b/docs/_static/example/event_listening.py
    index 2e6f026..ff8c146 100644
    a b def _render_graph(window, bandwidth_rates): 
    9393
    9494  # draw the graph
    9595
    96   for col in xrange(GRAPH_WIDTH):
     96  for col in range(GRAPH_WIDTH):
    9797    col_height = GRAPH_HEIGHT * download_rates[col] / max(max_download_rate, 1)
    9898
    99     for row in xrange(col_height):
     99    for row in range(col_height):
    100100      window.addstr(GRAPH_HEIGHT - row, col + 6, " ", DOWNLOAD_COLOR, curses.A_STANDOUT)
    101101
    102102    col_height = GRAPH_HEIGHT * upload_rates[col] / max(max_upload_rate, 1)
    103103
    104     for row in xrange(col_height):
     104    for row in range(col_height):
    105105      window.addstr(GRAPH_HEIGHT - row, col + GRAPH_WIDTH + 12, " ", UPLOAD_COLOR, curses.A_STANDOUT)
    106106
    107107  window.refresh()