Currently, os.path.join joins strings specified in its arguments, with one
string per argument.
On its own, that is not a problem. However, it is inconsistent with
str.join, which accepts only a list of strings. This inconsistency can
lead to some confusion, since these operations that have similar names and
carry out similar tasks have fundamentally different syntax.
My suggestion is to allow os.path.join to accept a list of strings in
addition to existing one string per argument. This would allow it to be
used in a manner consistent with str.join, while still allowing existing
code to run as expected.
Currently, when os.path.join is given a single list, it returns that list
exactly. This is undocumented behavior (I am surprised it is not an
exception). It would mean, however, this change would break code that
wants a list if given a list but wants to join if given multiple strings.
This is conceivable, but outside of catching the sorts of errors this
change would prevent, I would be surprised if it is a common use-case.
In the case where multiple arguments are used and one or more of those
arguments are a list, I think the best solution would be to raise an
exception, since this would avoid corner cases and be less likely to
silently propagate bugs. However, I am not set on that, so if others
prefer it join all the strings in all the lists that would be okay too.
So the syntax would be like this (on POSIX as an example):
>>> os.path.join('test1', 'test2', 'test3') # current syntax
>>> os.path.join(['test1', 'test2', 'test3']) # new syntax
>>> os.path.join(['test1', 'test2'], 'test3')
>>> os.path.join(['test1'], 'test2', 'test3')
>>> os.path.join(['test1', 'test2'], ['test3'])