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

Peter Funk pf@artcom-gmbh.de
Tue, 3 Apr 2001 13:44:00 +0200 (MEST)


Guido van Rossum:
[...]
> Well, that was one response.  Besides, it's easy to factor out two
> separate design decisions: (1) a string scanning mechanism that takes
> two strings (a format and an input string) and returns one or more
> values extracted from the input string according to the rules set by
> the format string, and (2) how to spell this: scanf(format, input) or
> format/input or input/format or whatever.
> 
> > I however often like the infix notation better.  
> 
> See my two examples above for a concern: already I cannot recall
> whether your PEP proposes format/input or input/format.  That's a bad
> sign for either spelling. :-)

Hmmm.... May be I've stressed the analogy to arithmetic a bit to far:

If the string interpolation operator were '*' instead of '%'
then you could think of "multiplying" a format string with one
or more values gives a result string which than represents some kind of
"product".  Taking this result string now as input to the scanning
operation is some kind of "division" reverting the previous string
interpolation operation.  From that POV it would be pretty obvious,
that "dividing" the input string by the format string as denominator
returns the values previously formatted into it.

But since the string interpolation operator is '%' the analogy from
multiplication to formatting is obviously not at all that obvious.  :-(

Regards, Peter