[Python-ideas] String interpolation again. (original) (raw)
Masklinn masklinn at masklinn.net
Fri Jul 23 16:14:59 CEST 2010
- Previous message: [Python-ideas] String interpolation again.
- Next message: [Python-ideas] String interpolation again.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2010-07-23, at 16:09 , Mike Meyer wrote:
In python, that would be making str.add (and friends) do the conversion. You'd run into the issues of writing
a + "foo"
witha
defining a custom_add_
, which would not perform string concatenation, as per Python's operator resolution order. That's what the "and friends" is for. str.radd is one of the friends. If the type of a refused to do the add, then str.radd would get it, and could do the conversion and concatenation. Of course, if the type of a did the add in some way other than via the conversion and concatenation, then that's what would happen. Which is one of the reasons this type of implicit conversion isn't right for Python.
Right. Because otherwise it should not be very hard (which doesn't mean it would be smart) to remove the type error from str.add and str.radd and just str() the argument if it isn't already a string.
- Previous message: [Python-ideas] String interpolation again.
- Next message: [Python-ideas] String interpolation again.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]