[Python-Dev] PEP 3000 and iterators

Guido van Rossum guido at python.org
Sun Sep 11 17:24:53 CEST 2005

On 9/10/05, James Y Knight <foom at fuhm.net> wrote:
> No, that cannot work. However, there is a very obvious and trivial
> solution. Do not remove dict.iteritems in Py 3.0. Py2.X programs
> wishing forward compat can   avoid dict.items and use instead
> dict.iteritems. In Py3.0, dict.items becomes a synonym for
> dict.iteritems and programs that don't care about compat with 2.X can
> just use dict.items from then on. And everybody can be happy. A small
> number of redundant methods is a small price to pay for compatibility.

But it breaks the desire to keep the Python 3.0 language clean from
deprecated features.

Given that I don't expect there will be much compatibility *anyway*, I
don't want to promise this. I expect that we'll have to write a
source-level translator -- which could replace all iteritems() calls
to items(), for example. Such a source-level translator may not be
able to reach perfection, but it should take care of the tedious tasks
and leave the rest up to manual polishing.

This doesn't mean that there's no point in trying to introduce certain
3.0 features in 2.x; it's always good to have early experience with a
new feature, and in some cases it *will* improve forward
compatibility. But just installing python3.0 as python and expecting
nothing will break is not a goal -- it would be too constraining.

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

More information about the Python-Dev mailing list