Skip to content

Commit 4bf61b5

Browse files
committed
Use next() builtin rather than method.
1 parent dc65cc6 commit 4bf61b5

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

pandas/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def iterpairs(seq):
519519
# input may not be sliceable
520520
seq_it = iter(seq)
521521
seq_it_next = iter(seq)
522-
_ = seq_it_next.next()
522+
_ = next(seq_it_next)
523523

524524
return itertools.izip(seq_it, seq_it_next)
525525

pandas/io/parsers.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,9 @@ def _next_line(self):
489489
raise StopIteration
490490
else:
491491
while self.pos in self.skiprows:
492-
self.data.next()
492+
next(self.data)
493493
self.pos += 1
494-
line = self.data.next()
494+
line = next(self.data)
495495
self.pos += 1
496496
self.buf.append(line)
497497

@@ -682,10 +682,10 @@ def _get_lines(self, rows=None):
682682
try:
683683
if rows is not None:
684684
for _ in xrange(rows):
685-
lines.append(source.next())
685+
lines.append(next(source))
686686
else:
687687
while True:
688-
lines.append(source.next())
688+
lines.append(next(source))
689689
except StopIteration:
690690
if len(lines) == 0:
691691
raise
@@ -757,10 +757,13 @@ def __init__(self, f, colspecs, filler):
757757
assert isinstance(colspec[1], int)
758758

759759
def next(self):
760-
line = self.f.next()
760+
line = next(self.f)
761761
# Note: 'colspecs' is a sequence of half-open intervals.
762762
return [line[fromm:to].strip(self.filler or ' ')
763763
for (fromm, to) in self.colspecs]
764+
765+
# Iterator protocol in Python 3 uses __next__()
766+
__next__ = next
764767

765768

766769
class FixedWidthFieldParser(TextParser):

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
'zip_safe': False,
4141
'install_requires': ['python-dateutil >= 2',
4242
'numpy >= 1.4'],
43+
'use_2to3_exclude_fixers': ['lib2to3.fixes.fix_next',
44+
],
4345
}
4446
if not _have_setuptools:
4547
sys.exit("need setuptools/distribute for Py3k"

0 commit comments

Comments
 (0)