[Python-ideas] Add `future_builtins` as an alias for `builtins`

Mathias Panzenböck grosser.meister.morti at gmx.net
Wed May 16 22:28:13 CEST 2012


If you look at the __future__ stuff one might get the idea to reverse it:


try:
	from __past__ import unicode_literals, future_builtins
except ImportError:
	pass

On 05/09/2012 08:48 PM, Sven Marnach wrote:
> With the reintroduction of u"Unicode literals", Python 3.3 will remove
> one of the major stumbling stones for supporting Python 2.x and 3.3
> within the same code base.  Another rather trivial stumbling stone
> could be removed by adding the alias `future_builtins` for the
> `builtins` module.  Currently, you need to use a try/except block,
> which isn't too bad, but I think it would be nicer if a line like
>
>      from future_builtins import map
>
> continues to work, just like __future__ imports continue to work.  I
> think the above actually *is* a kind of __future__ report which just
> happens to be in a regular module because it doesn't need any special
> compiler support.
>
> I know a few module names changed and some modules have been
> reorganised to packages, so you will still need try/except blocks for
> other imports.  However, I think `future_builtins` is special because
> it's sole raison d'être is forward-compatibility and becuase of the
> analogy with `__future__`.
>
> Cheers,
>      Sven




More information about the Python-ideas mailing list