On 29/01/2019 01:40, Jamesie Pic wrote:
... I'm still sometimes confused between the different syntaxes used by join methods:
0. os.path.join takes *args 1. str.join takes a list argument, this inconsistence make it easy to mistake with the os.path.join signature
It seems fairly consistent to make: os.path.join('a', 'b', 'c') short for: os.path.sep.join(['a', 'b', 'c'])
Also, I still think that:
'_'.join(['cancel', name])
Would be more readable as such:
['cancel', name].join('_')
Please, no. This would be un-Pythonic in my view. It makes so much more sense that str should have a method that takes an iterable, returning str, than that every iterable should have a join(str) returning str. Consider you get this kind of thing for free: "-".join(str(i) for i in range(10)) I learned enough Groovy last year to use Gradle and was so disappointed to find myself having to write: excludes: exclusions.join(',') // Yes, it's that way round :o Even Java agrees (since 1.8) with Python. Jeff Allen