|
|
|
|
|
by jrockway
5332 days ago
|
|
This argument is silly. Python is not some other programming language, so when you're writing Python, it doesn't matter what other programming languages do. If you use the same idioms in every programming language that you use, you're writing bad code in every programming language that you use. So don't do that. The reason why list(x) is better than x + [] is because list(x) works regardless of what type of iterable x is. x + [] only works on lists. |
|
A good analogy is probably assuming that pointer sizes are the same as int sizes in C. This assumption was safe for many years, but broke when 64-bit came along. Slices and adding lists will probably always return new lists in python, but it is still good not to depend on such behaviour.