Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It bothers me that majority of languages ignores a nice python approach. `', '.join(any_str_iterable)`. Instead of supporting join for myriads of containers there is a single str method.




Python's approach is one of the most confusing ways to possibly do it. Not having proper, discoverable methods is super annoying, and I need to look it up every time anew I use Python because it's so unintuitive.

Of course you can write a generic version of `mkString` (as this method is called in Scala), so it's also just one method no matter the container count.

The Python weirdness is actually a direct result from the language lacking generics…


From typing perspective there is no sense to have Container[T].join() -> str for any T.

I agree, but from convenience perspective there is a lot of sense. Java Streams is actually a good example of a "correct" design, but not very convenient.

That's my point. Python has convenient and good type design with str.join ignored by other languages.

For example I'm lost which abstract class to inherit in Scala to obtain mkString for my custom container.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: