Why doesn't join() call str() on its arguments?
Fredrik Lundh
fredrik at pythonware.com
Thu Feb 17 03:32:07 EST 2005
"news.sydney.pipenetworks.com" wrote:
>> Nick "Explicit is better than Implicit"
>
> Really ? Then why are you using python. Python or most dynamic languages are are so great because
> of their common sense towards the "implicit". You must have heard of "never say never" but "never
> say always" (as in "always better") is more appropriate here. There are many cases of python's
> implicitness.
a certain "princess bride" quote would fit here, I think.
> What about
>
> a = "string"
> b = 2
> c = "%s%s" % (a, b)
>
> There is an implicit str(b) here.
nope. it's explicit: %s means "convert using str()".
from the documentation:
%s String (converts any python object using str()).
> ''.join(["string", 2]) to me is no different then the example above.
so where's the "%s" in your second example?
</F>
More information about the Python-list
mailing list