Understanding Python's join() Method for Strings

Why is #Python's join() a STRING method, not a list method? x = 'this is a test'.split() '*'.join(x) ':::'.join(x) Not: x.join('*') Why not? The argument can be any string-returning iterable: '*'.join('abcde') '*'.join(str(x) for x in range(5)) '*'.join(open('filename.txt'))

  • No alternative text description for this image

...and Python's developers were smart enough to make these as methods, and not to have something as dumb as java.util.Arrays. Or whatever the heck PHP does.

To view or add a comment, sign in

Explore content categories