DEV Community

Discussion on: What was the most irritating quirk for you when you learned another language or stack?

Collapse
 
rdejuana profile image
Rodrigo DeJuana

Array to String joining in Python. The syntax is as follows:

array = ["apple", "banana", "pear"]
separator = ","
separator.join(array)

Why is the action on the separator?! In most other languages, the separator is optional, but here its where you start!

I'm a Ruby guy and my impression of Python at the time was that it more functional.
I would have expected

join(array, separator)
or
array.join(separator)

but not
separator.join(array)

Collapse
 
misobelica profile image
Mišo

Yes, this is pretty annoying. It was designed like this because you can apply str.join to every iterable object, not only array. The same way as len(iterable) is not specific to array but generic and that's why it's not a method of the array like array.len().