On 9/11/05, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote: > James Y Knight wrote: > > > Just to be clear, I do not want nor expect this. I wish to be able to > > specifically modify code with full knowledge of what has changed in > > Py3.0 such that it will work with both Py2.X and Py3.0. > > If you want these things to work in 2.x and 3.0, just use > iter(dict_instance) and list(dict_instance) as appropriate.
Simpler still, just use di.keys() but make sure you're only using the result to iterate over once without modifying the dict's key set. Or if you *have* to avoid creating a list in Py2.x, write your code to iterate over the dict itself even if you'd like itervalues or iteritems; you can always get the value explicitly by indexing the dict. IOW use the API whose name will remain but don't rely on the functionality that will change. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com