Skip to content

Make conversions of xrange() #10559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
unicode_literals)

import six
from six.moves import xrange, zip
from six.moves import zip
from itertools import repeat
import collections
import datetime
Expand Down Expand Up @@ -900,7 +900,7 @@ def get_split_ind(seq, N):

s_len = 0
# todo: use Alex's xrange pattern from the cbook for efficiency
for (word, ind) in zip(seq, xrange(len(seq))):
for (word, ind) in zip(seq, range(len(seq))):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use enumerate instead.

s_len += len(word) + 1 # +1 to account for the len(' ')
if s_len >= N:
return ind
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/sphinxext/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@
unicode_literals)

import six
from six.moves import xrange

import sys, os, shutil, io, re, textwrap
import sys, os, shutil, io, re, textwrap, itertools
from os.path import relpath
import traceback
import warnings
Expand Down Expand Up @@ -597,7 +596,7 @@ def render_figures(code, code_path, output_dir, output_base, context,
all_exists = True
for i, code_piece in enumerate(code_pieces):
images = []
for j in xrange(1000):
for j in itertools.count(0):
if len(code_pieces) > 1:
img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir)
else:
Expand Down