Collections of non-arbitrary objects ?
steve at holdenweb.com
Wed Jun 27 19:00:52 CEST 2007
> On Jun 26, 8:23 am, Bruno Desthuilliers <bruno.
> 42.desthuilli... at wtf.websiteburo.oops.com> wrote:
>> walterbyrda écrit :
>>>> You do program carefully, don't you ?-)
>>> I try. But things like typos are a normal part a life.
>> So are they in any language. I fail to see much difference here.
> For example: if I mis-type a variable name in C, the program will
> probably not even compile. Whereas, with Python, the program will
> probably run, but may give unexpected results.
>>> must think python has a lot of room for improvement since he's
>>> completely throwing out backward compatibility with python 3000.
>> Not "completely throwing out". Just allowing *some* major breakages -
>> the kind you usually get with each major release of other languages, but
>> that Python managed to avoid as much as possible so far.
> I don't know, but here is a direct quote from Guido's blog: "Python
> 3.0 will break backwards compatibility. Totally."
By which he means he is not, for this one major release only, committed
to maintaining backwards compatibility with previous versions (which was
pretty good, though not perfect).
>>> It seems to me that tuple are essentially immutable lists.
>> They are not (even if you can use them that way too). FWIW and IIRC,
>> this is a FAQ.
> A few posters here have stated that tuples are not just immutable but
> when I compare lists, to tuples, I notice that both are ordered
> collections of arbitrary objects, with the primary difference being
> that list are mutable, and tuples are not. It seems to me that if a
> list were immutable, it would be a tuple. That is the one big
> Tuples have been compared to records/structures in other languages.
> But, in general, I can not use a for loop to loop through the fields
> in a record, and I can not sort those fields either.
Think of a tuple as an ordered collection. A given element's ordinal
position indicates its semantics (meaning, significance), and generally
it won't make sense to iterate over the elements of a tuple (though
naturally that doesn't stop people, and neither does the interpreter).
Lists are intended for numbered "sets of things", and when all the
"things" are of the same or closely-related types it's natural to
iterate over them.
Those who don't "see the need" for tuples need not use them, and their
programs probably won't be much worse as a result.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list