terminological obscurity

E

Elaine Jackson

Some questions from a curious monkey.

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?

#################################################################

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?

#################################################################

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.)

#################################################################

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 " count as a 'name'?
 
T

Terry Reedy

Elaine Jackson said:
Some questions from a curious monkey.

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?

Is history a special reason? Once upon a time, (before 2.2) tuples (and
some other types) had no methods. Those it now has are generic object and
sequence methods. Guido did not add the two non-mutating list methods
because he does not consider them needed for tuples. That is related to
his view that tuples are for hetero and not for homo sequences.

Others have made the same observation you did. Google might reveal more,
or some posts might be on the PyDev archives.

#################################################################
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()?

I personally do not think of objects as 'belonging' to a namespace. They
'exist' in a separate 'dataspace' and get non-exclusively associated with 0
or more names in 0 or more namespaces.

If the above is the complete program up to that point, then the empty tuple
is not directly associated with 'king', the only remaining name, but is
associated with the first slot of king, king[0]. So pick your answer or
reformulate your question.
More generally, is there a terminological way to
distinguish between (1) a function from a set of names into a set of
objects,
a namespace
and (2) the aforementioned set of objects?
a dataspace

#################################################################
Is there a handy noun that refers to sameness of identity in the same way that
'equality' refers to sameness of value?
identity

('Identicalness' is pretty clumsy, and
'identity' is confusing, since it already has a meaning that is closely related
but needs to be kept distinct.)

English words sometimes have similar but distinct meanings. In brief, my
dictionary says 'identity': 1. sameness; 2. individuality.

#################################################################
A question about terminology ('name'):

Suppose X is a container that contains n items (incidentally, is 'items' the
right term?)

Yes (which is to say, I use it all the time ;-).
and i in an integer with 0<=i<=n. Does " X " count as a 'name'?


Only allegorically in that it does identify an item. In an expression
context, 'X' is an expression. To the left of '=', it is a 'target':
names are a subset of targets.

'name' is pretty strictly defined as <alpha> <alnum>*. There are proposals
to expand the set but that is another thread (and controversy).

Terry J. Reedy
 
D

Donn Cave

"Elaine Jackson said:
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 " 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, (e-mail address removed)
 
A

Aahz

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?

Objects don't have a namespace, only names and attributes do. Names are
bound to objects. All objects are global to the entire interpreter (not
just within a module by the usual meaning of "global").

It's not clear to me what your (1) and (2) are supposed to refer to.
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.)
"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
" count as a 'name'?


"Item" or "element" are both correct. X is a target. See the
Language Reference, section 6.3.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top