On 9 February 2013 20:08, R. David Murray wrote:
>
>
> Especially given that there is already a try/except there, this seems
> fine to me. I think perhaps the error text would be better if it
> referred only to the type that is invalid, not to str. So something
> like:
>
> TypeError("object
On 9 February 2013 17:15, R. David Murray wrote:
>
> No, it is more the difference between *statically* typed and dynamically
> typed. Python is a strongly typed language (every object has a specific
> type).
>
>
>
Yes, sorry, I think I probably have my terminology confused. What I really
meant
R. David Murray bitdance.com> writes:
> The reason we avoid such type checks is that we prefer to operate via
> "duck typing", which means that if an object behaves like the expected
> input, it is accepted. Here, if we did an explicit type check for str,
> it would prevent join from working on
If a function (or other non-string object) is accidentally passed as an
argument to os.path.join() the result is an AttributeError:
In [3]: os.path.join(fn, "path")
> ---
> AttributeErrorTraceback