references/pointers in Python?

Alex Martelli aleax at aleax.it
Thu Sep 13 10:10:47 EDT 2001


"Anton Lavrik" <asl at tepkom.ru> wrote in message
news:mailman.1000327335.10232.python-list at python.org...
> On Wed, Sep 12, 2001 at 12:06:06PM -0700, Cliff Wells wrote:
> > On Wednesday 12 September 2001 10:09, you wrote:
> >
> > > And does this all mean that I should move on to Perl or any other
> > > language, if I need effective implementation of references :) ?

Why would you NEED them?  An example, please!  One that cannot
be handled better with other tools.

> > be using the most efficient method.  I wonder if you really need
references
> > or if there is a more "Pythonish" way of accomplishing your goal.
> >
> You are right! I'v already found one wonderfull solution for the
> problem. Actually references were not the only way for making it.

Were they even the BEST way, if not the only one?

> But anyway, I can't understend why such powerfull Perl-like references
> haven't been implemented in Python.

If we can't find an example that is best implemented with
references, I think it's clear why one would rather not have
them in the language -- why should the language mislead its
users towards a second-best (at best:-) approach?-)

And I can't think of one.  Since, in Python, every variable,
every object attribute, every item in a collection, is ALWAYS
a reference to some object (just about as in Java, except
that Java has some cases where values rather than references
are used -- Python is more regular, it's ALWAYS references);
therefore, WHAT need could we possibly have for "explicit"
references *in addition*?  Java doesn't have explicit references,
neither does Python, neither suffers thereby.

*WEAK*-references (garbage-collectable ones) are another
matter, and indeed both languages do supply them as part
of their respective standard libraries.  But I don't think
that this is what you mean...?


Alex






More information about the Python-list mailing list