From The Zen of Python:
Explicit is better than implicit.
In my opinion, your first example is explicit. It takes two values and processes them in well-understood ways. Although it "feels" a little strange to new Python programmers, it behaves just like expect. list.extend
accepts lists, so it treats strings like a list of chars.
Your proposal alters the semantics of list.extend
to be equivalent to list.append
, but only when dealing with strings. That would be a real surprise to someone who wants your function to treat your strings as lists of chars and who would then have to call it like test(x,list('test'))
.
You can do what you're asking, but please don't. :-)