Brython - Python in the browser
steve+comp.lang.python at pearwood.info
Sat Dec 22 12:05:05 CET 2012
On Sat, 22 Dec 2012 20:08:25 +1100, Chris Angelico wrote:
> I don't see "string % tuple" as a good syntax; I prefer to spell it
Very possibly one of the worst names ever from a language that excels at
bad names. "Sprint f"? WTF?
Certainly not appropriate for Python, where a sprintf equivalent would
return a new string, rather than automatically print the result. Oh
wait... C's sprintf doesn't automatically print either.
> When it
> comes to operators on strings, what I'd prefer to see is something that
> does more-or-less what the operator does with integers - for instance:
> "This is a string" / " " ==> ["This","is","a","string"]
I don't see the connection between the above and numeric division. If it
"This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
(and presumably // 3 would be the same except the "g" would be dropped)
then I could see the connection. But there's no relationship between
numeric division, which divides a number up into N equal-sized parts, and
string splitting as you show above.
Of course, if we can just invent a meaning for the % operator that has
nothing to do with either percentages or numeric modulo, then we could
equally invent a meaning for / for strings. But if we did so, it still
wouldn't have anything to do with numeric division.
> Taking a string modulo a tuple doesn't make any sense in itself,
Taking an integer cross an integer doesn't make any sense if you haven't
learned the meaning of the + operator. Why insist that only string
operators must make inherent sense to somebody who doesn't know what the
operator means? If we're allowed to learn the meaning of + * and &, why
not % as well?
More information about the Python-list