[Python-Dev] s1 == (sf % (s1 / sf))? A bad idea?
Jeremy Hylton
jeremy@alum.mit.edu
Tue, 3 Apr 2001 21:17:42 -0400 (EDT)
>>>>> "TP" == Tim Peters <tim.one@home.com> writes:
TP> Making it a method of the format string would be fine (why the
TP> format string? because capturing a bound method object like
TP> parse3d = "%d %d %d".whatever
TP> would be darned useful, but the other way wouldn't be).
TP> Finally, since .scanf() is a rotten method name (like .join()
TP> before it, it doesn't make clear which operand is scanned and
TP> which format), try something like format.scanning(string)
TP> instead.
My preference would be to have a separate module with the necessary
support. It sure would be easy to add to the language.
I imagine something like this:
import fileinput
import scanf
fmt = scanf.Format("%d %d %d")
for line in fileinput.intput():
mo = fmt.scan(line)
if mo:
print mo.group(1, 2, 3)
Jeremy