> [this] distinction [...] is only useful in a statically-typed languages
...like Erlang.
Re:Anti-Patterns in Python Programming
by dragonwriter on Thursday July 10, 2014 @09:56AM
(#8014962)
Yeah, while snarkily made its a good point that Erlang does make use of it without being statically typed.
There is a deep difference that goes beyond use of tuples in language approach between Python and Erlang here where it comes to types in which Erlang, while dynamically typed, has a deep concern for types in its pattern matching system to make path decisions while Python is very much centered on using dynamic OO techniques -- how objects respond to messages -- to do that.
So I'd still say its the same kind of deep language approach difference at work.
So why does Python distinguish between a list and a tuple at all?
Re:Anti-Patterns in Python Programming
by dragonwriter on Thursday July 10, 2014 @09:48AM
(#8014930)
Because the distinction between a mutable list and an immutable list is still meaningful in a dynamic language like python.
No, it allows them because the distinction that those restrictions are founded on is only useful in a statically-typed languages, and Python isn't statically typed.
> For instance, should a Vector be a list or a tuple?
A real vector/array should be its own data type (probably implemented in a C, or similar low-level, extension) that happens to implement the interface expected of an indexable, iterable collection, neither a list nor a tuple.