"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.
I'm not really familiar with it, can you enlighten please.
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()".
ok you got me there, although it must be bad practice compared to
c = "%s%d" % (a, b)
because this is much more explicit and will tell you if b is ever anything other then an integer even though you may not care.
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>
I'm not sure if this has been raised in the thread but I sure as heck always convert my join arguments using str(). When does someone use .join() and not want all arguments to be strings ? Any examples ?
Regards,
Huy
-- http://mail.python.org/mailman/listinfo/python-list