[Python-Dev] s1 == (sf % (s1 / sf))? A bad idea?

Tim Peters tim.one@home.com
Tue, 3 Apr 2001 20:05:50 -0400


[Peter Funk]
> I believe a strawman derived from the UserString class could be done
> in pure Python.  But I'm sorry: I've no time for this during April.

sscanf for Python gets reinvented like clockwork; e.g., see

ftp://ftp.python.org/pub/python/
    contrib-09-Dec-1999/Misc/sscanfmodule.README

for 1995's version of this crusade.

> I'm also not sure, whether this is really a worthwile effort and
> whether I should champion this idea further.  From Pauls response I
> got the impression that people already consider the '%' string
> interpolation operator as a language wart rather than an elegant
> feature.

Not me!  Infix "%" is great.  But while "%" was mnemonic for the heavy use of
"%" in format strings, "/" doesn't say anything to me.  Combine that with the
relative infrequency of sscanf vs sprintf calls (in C code, Perl code, or (I
sure suspect) in Python code too), and I'm -1 on infix "/" for sscanf.

Making it a method of the format string would be fine (why the format string?
because capturing a bound method object like

    parse3d = "%d %d %d".whatever

would be darned useful, but the other way wouldn't be).

Finally, since .scanf() is a rotten method name (like .join() before it, it
doesn't make clear which operand is scanned and which format), try something
like format.scanning(string) instead.

language-design-is-easy<wink>-ly y'rs  - tim