[Numpy-discussion] loadtxt bug?

Alan G Isaac aisaac@american....
Thu Nov 22 22:14:07 CST 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)]
    '1234'

So I propose this should be::

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

Am I right?

Cheers,
Alan Isaac





More information about the Numpy-discussion mailing list