What other languages use the same data model as Python?

Chris Angelico rosuav at gmail.com
Sun May 8 02:32:04 EDT 2011


On Sun, May 8, 2011 at 4:16 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On Sun, 08 May 2011 10:54:57 +1200, Gregory Ewing
> <greg.ewing at canterbury.ac.nz> declaimed the following in
> gmane.comp.python.general:
>
>>
>> What would *you* call a[i]?
>>
>        Depending upon the nature of the beast, I'd be tempted to call it a
> "fully qualified name" or a "partially qualified name"
>
>        a = [1, 2, 4, ("c", "d", "e")]

Why is an integer more or less important than a tuple? a[3] is no less
qualified than a[2]; each of them points to an object. One of those
objects happens to contain other objects.

What if you had:
stdio = [stdin, stdout, stderr]

They might be 'file' objects, or they might be integers (unlikely in
Python), or they could be pipes or other file-like objects, or they
might be some kind of special tee object that contains two file
objects. Let's say your standard I/O uses the notation
stdout.write('message') and that you have a subclass of tuple that
will apply the . operator to all its members (is that possible in
Python? If not, pretend it is). You could then execute
stdio[1]=(stdout,teeobject) to easily copy your screen output to
another file. At this point, you can actually pretend that stdio[0]
and stdio[1] are identical objects, but you can use stdio[1][1] and
you can't use stdio[0][1] - which means that, per your definition, one
of them is only partially qualified.

As Inigo Montoya said, there is too much - let me sum up. Lists/tuples
and integers are equally objects, so whether or not you have a 'name'
is not affected by what type of object it points to.

Chris Angelico



More information about the Python-list mailing list