[Python-Dev] PEP 3000 and iterators

Guido van Rossum guido at python.org
Sun Sep 11 04:13:33 CEST 2005

On 9/10/05, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> On 9/9/05, Guido van Rossum <guido at python.org> wrote:
> > For methods on standard objects like dicts it's not really possible
> > either way; the type of a dict is determined by the module containing
> > the code creating it, not the module containing the code using it.
> I had that in mind when I wrote my post; changing types is not the
> way, that will not work. That is why I proposed __future__ (I really
> do not know very well the implementation details of that feature)
> because I think the parser/compiler can (magically) make the
> replacements, e.g.  dict.items -> dict.iteritems for Py2.X series in
> codes *using* dicts . Do you think something like this could be
> implemented in a safer way?

Please trust me. It can't be made to work. The compiler doesn't know
the types of the variables so it doesn't know whether in a particular
occurrence of the expression 'x.items", x is a dict or not.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list