[Python-Dev] [Python-3000] dict.items as attributes [Was: The bytes type]

Nick Coghlan ncoghlan at gmail.com
Thu Jan 18 13:02:49 CET 2007


Jim Jewett wrote:
> On 1/17/07, Thomas Wouters <thomas at python.org> wrote:
>> On 1/16/07, Jim Jewett <jimjjewett at gmail.com> wrote:
>>> Other than dict.items (and .keys and .values) returning a non-list,
>>> are there any other cases where the Py3K idiom can't already be used
>>> in (or at least backported to) Py 2.x?
> 
>> The aim for 2.6 should be to have all the new features that 3.0 has,
>> as well as full backward compatibility ...
> 
> And I'm asking if there are any real barriers to this.  Some people
> have suggested that they'll have to maintain separate code bases.  So
> far, the closest I've seen[1] to something that can't use
> common-subset is wanting an iterator over a mapping.

To help with the transition code, could we have a 'py3migration' module 
that looked something like:

   if sys.version_info >= (3, 0, 0):
       from _py2compat import *
   else:
       from _py3compat import *

By providing functions like dkeys(), ditems(), dvalues() and maybe a few 
others in that module, this could allow code that needs to work in both 
environments to be written, without causing significant pain to pure 
Python 2 code or to pure Python 3 code.

OK, so it would mean there's still some backward compatibility cruft in 
Py3k, but one module seems a small price to pay for a single obvious way 
to handle semantic changes in the builtin APIs.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list