(Hope no-one minds me keeping this thread alive --- as I said in my first reply to Tim Peters, there's either something very fundamental here, or a "just-so" story...) > > > Tim Peters wrote: > > > At heart, tuples are for Cartesian products of a fixed number of > > > possibly differing types, while lists are for arbitrary-length > > > sequences of a single type. > > Greg Wilson wrote: > > Fooey. Programmers raised on C, Fortran, Pascal, or Java would tell you > > that the elements of [1, "two"] have different types. So (I believe) > > would most ten-year-olds, and they'd be right: I can't add 7 to "two", or > > take a slice of 1. I can grandparent them by fiat with a type "any", but > > that smells like I've decided what answer I want, and am now inventing > > what I need to get there. > Tim Peters wrote: > The C++, Fortran, Pascal or Java programmer can't *spell* the list [1, > "two"] in their languages without playing casting tricks. Greg Wilson wrote: The fact that their current language doesn't allow this is irrelevant to the argument. Show them [1, "two"] and they (a) understand it, and (b) think it's cool; show them (1, "two") as well and they become confused. > Tim Peters wrote: > Of course the elements are of different types, and for that very > reason it's better to use a tuple here instead (especially if it's > always of length two!). Greg Wilson wrote: But *why* is it better? Or to put it another way: If tuples didn't already exist, would anyone ask for them to to be added to the language today? > Tim Peters wrote: > "Different data structures for different purposes" is as Pythonic as > "different syntax for different purposes", and paying attention to > this can improve your (that's the generic "your") Python programming > life. Greg Wilson wrote: Analogic reasoning makes me nervous, as it is most often used to transfuse legitimacy from the defensible to the suspect. > Tim Peters wrote: > Start from ground zero and try to explain why Python has both ints and > floats: there is no *obvious* reason (even less so for having both > ints and longs, btw). Greg Wilson wrote: I've never had any trouble explaining int vs. float to students at any level; I've also never had any trouble explaining int vs. long (memory vs. accuracy). Thanks for your reply, Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4