module confusion

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Fri Oct 5 05:06:10 CEST 2007

In message <slrnfg9ru0.1lk.horpner at>, Neil Cerutti wrote:

> On 2007-10-03, Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand>
> wrote:
>> In message <874ph8sdhx.fsf at>, Ben Finney wrote:
>>> Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:
>>>> On my Gentoo system:
>>>>     >>> import os
>>>>     >>> os.path
>>>>     <module 'posixpath' from '/usr/lib64/python2.5/posixpath.pyc'>
>>>> It's just a variable that happens to point to the posixpath module.
>>> There's no "pointing" going on. It's another name bound to the
>>> same object, of equal status to the 'posixpath' name.
>>> Python doesn't have pointers, and even "variable" is a
>>> misleading term in Python. Best to stick to "name" and "bound
>>> to".
>> In Python, all names _are_ variables. They are not "bound" to
>> objects. The value of os.path is a pointer. It's implemented as
>> a pointer, it has all the semantics of a pointer.
> No. A pointer is also an iterator.
> void duplicate(char *d, const char *s)
> {
>   while (*d++ = *s++)
>     ;
> }

So if you can't do pointer arithmetic, then it's not a pointer? Trying this:

    void duplicate(void *d, const void *s)
      while (*d++ = *s++)

I get:

    test.c: In function 'duplicate':
    test.c:3: warning: dereferencing 'void *' pointer
    test.c:3: warning: dereferencing 'void *' pointer
    test.c:3: error: invalid use of void expression

So you can't do arithmetic or iterate with a void * pointer. Does that mean
it's not really a pointer?

More information about the Python-list mailing list