[Numpy-discussion] loadtxt bug?

Alan G Isaac aisaac at american.edu
Thu Nov 22 23:14:07 EST 2007

In numpy.core.numeric.py you will find loadtxt, which uses
the following::

        line = line[:line.find(comments)].strip()

I believe there is a bug here (when a line has no comment).
To illustrate::

    >>> line = "12345"
    >>> comments = "#"
    >>> line[:line.find(comments)]

So I propose this should be::

            line = line[:line.index(comments)].strip()
        except ValueError:
            line = line.strip()

Am I right?

Alan Isaac

More information about the NumPy-Discussion mailing list