[SciPy-user] fromfile, item, what other output than stdout / stderr is used ?
Mon May 11 17:48:35 CDT 2009
Robert Kern wrote:
> But that doesn't let you express, "read at most this number of items,"
> which is really useful and is very common in file-reading APIs.
fair enough --
>> maybe a flag?
> If it makes you feel better, you may consider the warnings mechanism
> to be just such a flag, only it uses a Python-standard mechanism for
> controlling such behavior.
no, it doesn't -- I don't think warnings are designed for this sort of
>>> This lets you either silence
>>> the warning or turn it into an exception depending on your use case.
I've been a pythonista for years, and I have no idea how to turn a
warning into an exception, and I DID just spend some time trying to
figure it out -- it does not look easy. Maybe it is, but if it's hard to
figure out, and it won't dawn on many users that they need to, there
will be bugs.
I think we agree that fromfile() needs a way to spell:
"read at most this number of items,"
Why not spell that explicitly? we have "count" to specify whether or not
you want a specific number of items. We could have max_count or
whatever. I don't care how it's spelled but I do want to be able to
explicitly spell which I want.
In any case, having the warning printed with C stdout is not ideal.
Pauli Virtanen wrote:
> Not completely true: if it can't read any items, it either raises
> MemoryError. Also, for sep != '' it returns read_count+1 items, the
>last one containing junk. A bug, methinks...
right -- for the record, I wasn't guessing, I was recalling problems
I've had in the past. though I should have tested first.
Anyway, fromfile needs attention -- we've had discussions about it in
the past, but no one has found the time and inclination to give it the
attention it needs (including me).
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the SciPy-user