0
why built in functions with the same purpose in python are called differently
the list function: s = 'spam' t = list(s) split : s = 'pining for the fjords' t = s.split() so why list function can't be called like s.list() and or why the split can't be called like t=split(s) , I know that one takes argument , another not, but they serve almost the same purpose
4 Answers
+ 2
list() does not work on just one type, so it can't be a method.
.split() on the other hand works just with strings.
+ 1
Look up the difference between functions and methods.
+ 1
and when I want to think about the purpose of them both, which is turning a string into a list, how would I know or remember that list a function and split is a method ?