Why doesn't join() call str() on its arguments?

Nick Vargish nav+posts at bandersnatch.org
Thu Feb 17 08:09:39 EST 2005


"news.sydney.pipenetworks.com" <nytimes at swiftdsl.com.au> writes:

> Really ? Then why are you using python.

Try "import this" at a Python prompt. I didn't invent "Explicit is
better than implicit."

> Python or most dynamic languages are are so great because of their
> common sense towards the "implicit".

Python is not "most dynamic languages", and does not seem to
implicitly "cast" objects into other types. Python may be "dynamic",
but it's also "strongly typed", a feature I consider a benefit, though
you are of course free to disagree.

> c = "%s%s" % (a, b)
> There is an implicit str(b) here.

Not if you read the docs, as another poster has pointed out.

> ''.join(["string", 2]) to me is no different then the example above.

TypeError: sequence item 1: expected string, int found

Which pretty much supports my initial argument -- if a non-string got
into the list, something needs to be fixed, and it isn't the behavior
of the join() method!

Nick

-- 
#  sigmask  ||  0.2  ||  20030107  ||  public domain  ||  feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')



More information about the Python-list mailing list