module confusion

Steven D'Aprano steve at
Thu Oct 4 11:28:01 CEST 2007

On Thu, 04 Oct 2007 11:11:03 +1300, Lawrence D'Oliveiro wrote:

> In Python, all names _are_ variables. They are not "bound" to objects.

The general convention among Python programmers is to describe names 
being bound to values. While the analogy to real life binding of objects, 
it's close enough to be useful.

> The value of os.path is a pointer. It's implemented as a pointer, it has
> all the semantics of a pointer.

Ah, I see you are a devotee of Humpty Dumpty:

    "When I use a word," Humpty Dumpty said, in rather 
    a scornful tone, "it means just what I choose it to 
    mean-neither more nor less." 

    "The question is," said Alice, "whether you can 
    make words mean so many different things." 

    "The question is," said Humpty Dumpty, "which is to 
    be master -- that's all."

The rest of the world understands pointers to be in the sense of pointers 
in C, Pascal and similar: a low level construct that is to all extents 
and purposes a memory location whose content is itself a memory location.

Oh sure, I suppose there are a few pedants who insist that "pointer" just 
means "something which points to something else". There may even be a 
language or two whose users regularly use the term "pointer" to mean 
something other than the common usage, and may never have been exposed to 
the common usage.

And thus, satisfied in their own mind that *technically* they're right, 
or at least not provably wrong, the pedants insist on calling Python 
names "pointers" regardless of the confusion it confuses to the majority 
of programmers and despite the violence they have to do to the human 
language for it to work.

Of course, we can *easily* find out what the type of os.path is. Python 
allows us to interrogate any object and find out its type:

>>> import os
>>> type(os.path)
<type 'module'>

It's a module, not a pointer. End of story.

> Honestly, why do people react to the word "pointer" as though computers
> have to wear underwear to conceal something shameful going on in their
> nether regions?

The real question is why people insist on hammering the square peg of C 
terminology into the round holes of Python's object model.


More information about the Python-list mailing list