Make it immutable unless you've got a good reason not to.
For example, in #Python, prefer tuples to lists.
good advice. Though a frozen list is probably a better suggestion as a tuple is subtly different than a list.
@freemo I haven't really worked with frozen lists. Can you give an example where a tuple wouldn't suffice?
@freemo Hmm. I'm not even sure how to write that function using a list. Is it done with type hints?
I wasn't aware that tuples and lists interacted with types differently.
@freemo Interesting!
@peterdrake Yea I learned that one the hard way a while ago.. Since tuples are builtin to python it looks like a natural solution... sadly it can bite you int he ass.
@freemo @peterdrake Is the origin of tuples and lists in Python; come from ML in this form
@freemo @peterdrake Huh,... Not sure if I misunderstand you but:
```
from typing import Tuple
def function(intup: Tuple[int, ...]):
print("%s" % (intup,))
```
would literally be it. Type hint `Tuple[int, ...]` literally means - tuple of any size, with all items being integers.
With that particular type hint you could pass in (5, "hello") since it only type checks the first entry and all other entries can be anything.
@freemo @peterdrake As far as Python, interpreter, is concerned - you can still pass anything there. Type hints are just that - runtime doesn't enforce anything. But any decent toolkit will read this as - tuple of any size with all items being int.
hmmm now i need to open an interprier.. wasnt that long ago i ran into that problem but it may have been becauseof the flavor of linter I was using.
Ok so just checked and the standard is explicitly written to accept it as a homogonous type if there is just one argument and the ellipsis
So to correct my earlier statement, the reason a frozen list is better is because its still a list.. If you have a function where the type hint requires it take a list then you can pass a mutable or immutable list to it, and cant pass a tuple. So they arent interchable as they have different types.
@freemo @casastorta Could you use Sequence as a type?
@peterdrake @freemo Not completely sure what's the ask, but along the same line as we've discussed before in this thread, according to Python doc - yes:
https://docs.python.org/3/library/typing.html#type-aliases
It's literally given as example:
```
def broadcast_message(message: str, servers: Sequence[Server]) -> None:
...
```
@peterdrake yes its done with type hints. There is no way with tupples using type hints to say "a tuple of any size where all members are integers".