4 ms·
Because "list of string" is not a type in Python. Why would you put a method on a class if only a small subset of it can use it?
by linkdd 6y ago
Because "list of string" is not a type in Python.
Why would you put a method on a class if only a small subset of it can use it?
- Mathnerd314 6y agoThat happens all the time, since Python is dynamically typed. For example a[10] gives an IndexError if a has less than 11 elements. So with static typing, we should restrict indexing to ensure that the number of elements needed are present, and remove indexing from general lists. But you wouldn't remove indexing from lists, that's one of the main functions...
- matt_kantor 6y agoEither way it's a partial function that is not defined for most of its domain. The only difference is how its arguments (including self) get arranged at call sites, right?