terminological obscurity

Donn Cave donn at u.washington.edu
Fri May 21 16:31:33 EDT 2004


In article <L6erc.519686$Pk3.412259 at pd7tw1no>,
 "Elaine Jackson" <elainejackson7355 at home.com> wrote:

> All tuple methods are also list methods, and most list methods are also tuple
> methods; among those that are NOT also tuple methods, there are exactly two
> ('count' and 'index') that do not involve mutation. Is there any special 
> reason
> why they AREN'T also tuple methods?

Not to speculate on the reason (that would be for Guido or someone
who channels him to say), but suppose you accept the proposition that
a tuple is not just an immutable list, it's intended to serve in a
really distinct role.  Now you can invert your question to ask, what's
the apparent role of a sequence type that isn't interested in its
length, nor in sequential searches?

If you look at common use of tuple in the core language, I think it
might be fairly clear what that's about.  Take dict.items(), for
example - a list, of tuples.  The list is not a list because we want
it to be mutable (what a horrible thought), but because it's a
collection of conceptually similar objects ... so naturally, we
want to know how many (length) and maybe we'd be interested in
searching the list for things (though that would probably be silly
in this particular case.)

On the other hand, the key, value pair is a tuple because it always
contains two values, and they're not interchangeable at all.  What
good is the length here?  If it isn't two, something has gone very
wrong.  It makes no sense to apply a search indiscriminately to the
values of a tuple, because they lose their meaning out of context.


> A question about terminology ('namespace'):
> 
> >>> prince=tuple()
> >>> king=[prince]
> >>> del prince
> 
> At this point, does the object formerly known as prince belong to the 
> namespace
> implemented by globals()? More generally, is there a terminological way to
> distinguish between (1) a function from a set of names into a set of objects,
> and (2) the aforementioned set of objects?

Well, the "prince" binding disappears, but the object continues to
belong to it indirectly, through that list reference.  The more
general question you pose is not clear to me.

> Is there a handy noun that refers to sameness of identity in the same way 
> that
> 'equality' refers to sameness of value? ('Identicalness' is pretty clumsy, 
> and
> 'identity' is confusing, since it already has a meaning that is closely 
> related
> but needs to be kept distinct.)

What meaning is that?  I would use identity.

> A question about terminology ('name'):
> 
> Suppose X is a container that contains n items (incidentally, is 'items' the
> right term?) and i in an integer with 0<=i<=n. Does " X[i] " count as a 
> 'name'?

I imagine in some contexts we may use name that way, as an expedient
in casual usage, but I hope it isn't official nomenclature.  You could
call it a "binding".  (If you're trying to square this all up in some
kind of CS context, see if you can compare the Lisp usage of that term.)

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list