diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-06 11:46:39 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-15 08:44:49 -0600 |
commit | c6de09799decbb22bb2d7a44036f53c30356edda (patch) | |
tree | cdd392afe5ecd5cc185c45b1387c54712e93ca2c /numpy/lib/npyio.py | |
parent | 6c47259eec0ec20c1150c2b29994de59a3158964 (diff) | |
download | numpy-c6de09799decbb22bb2d7a44036f53c30356edda.tar.gz |
2to3: Apply next fixer.
The next builtin has been available since Python 2.6 and allows
`it.next()` to be replaced by `next(it)`. In Python 3 the `next` method
is gone entirely, replaced entirely by the `__next__` method. The next
fixer changes all the `it.next()` calls to the new form and renames the
`next` methods to `__next__`. In order to keep Numpy code backwards
compatible with Python 2, a `next` method was readded to all the Numpy
iterators after the fixer was run so they all contain both methods. The
presence of the appropriate method could have been made version
dependent, but that looked unduly complicated.
Closes #3072.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 733868780..2154acdce 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -785,14 +785,14 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, # Skip the first `skiprows` lines for i in range(skiprows): - fh.next() + next(fh) # Read until we find a line with some values, and use # it to estimate the number of columns, N. first_vals = None try: while not first_vals: - first_line = fh.next() + first_line = next(fh) first_vals = split_line(first_line) except StopIteration: # End of lines reached @@ -1344,13 +1344,13 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skip_header = skiprows # Skip the first `skip_header` rows for i in range(skip_header): - fhd.next() + next(fhd) # Keep on until we find the first valid values first_values = None try: while not first_values: - first_line = fhd.next() + first_line = next(fhd) if names is True: if comments in first_line: first_line = asbytes('').join(first_line.split(comments)[1:]) |