[Python-Dev] s1 == (sf % (s1 / sf))? A bad idea?
Greg Ward
gward@python.net
Sun, 15 Apr 2001 12:24:29 -0400
On 14 April 2001, Dinu Gherman said:
> I'd like to support Peter's proposal for having *some* kind
> of inverse mechanism to string formatting using '%'. Now, that
> doesn't mean anything, of course, but no matter what the syn-
> tax would look like: I'd prefer having that feature over not
> having it and I'll give an example below.
But we already have one: re.match (and friends). Regexes are vastly
more powerful, predictable, reliable, and (to me at least)
comprehensible than scanf() format strings. I've never understood how
scanf() works, and I don't see a great burning need to add scanf() to
Python.
Adding syntactic sugar for scanf() in the form of overloading "/" seems
like a *really* bad idea, too. ("%" is a nice operator because printf()
format strings use "%" a lot, not because formatting a string has
anything remotely to do with modulo arithmetic.) If scanf() really
needs to be in Python, write Modules/scanfmodule.c, build it by default,
and be done with it. Or *maybe* make it a string method, if enough
people think it's useful.
Greg
--
Greg Ward - just another Python hacker gward@python.net
http://starship.python.net/~gward/
When you make your mark in the world, watch out for guys with erasers.