terminological obscurity

Dan Bishop danb_83 at yahoo.com
Sat May 22 01:06:29 EDT 2004


Grant Edwards <grante at visi.com> wrote in message news:<slrncastid.5mc.grante at grante.rivatek.com>...
> On 2004-05-21, Donn Cave <donn at u.washington.edu> wrote:
> 
> >> For example, why shouldn't index() find an object in a
> >> non-homogeneous sequence? Either the object is in the sequence or
> >> it's not. If it is, there is an index that corresponds to it.
> >
> > For example,
> >   tm = time.localtime(time.time())
> >   i = tm.index(5)
> >
> > What would that mean?
> >
> > It's absurd to search for the location of a value in a tuple,
> > because the values don't have any meaning independent of their
> > location.
> 
> OK, I see what you mean.  That brings up the question of why
> use integer indexes to access members of a group of objects
> when the order of the objects is meaningless?

The order of a list can be meaningful.  For example, you might want to
arrange items in chronological order, or alphabetical order.  What do
you think .sort() is for?

The difference is that for tuples, the ordering affects the entire
meaning of the data.  As I'm writing this, the date/time tuple for the
current local time starts with (2004, 5, 21, 23, 59, 4).  This is not
conceptually equivalent to the rearrangement of (2004, 4, 5, 21, 23,
59), because it represents a different date and time.



More information about the Python-list mailing list