[Python-Dev] PEP 408 -- Standard library __preview__ package
Eli Bendersky
eliben at gmail.com
Fri Jan 27 17:45:27 CET 2012
>> Something along the lines of :
>>
>> if sys.version_info[:2] == (3, X):
>> from __preview__ import example
>> else:
>> raise ImportError( 'Package example is only available as preview in
>> Python version 3.X. Please check the documentation of your version of
>> Python to see if and how you can get the package example.' )
>
>
> A more normal incantation, as is often the way for packages that became
> parts of the standard library after first being a third party library
> (sometimes under a different name, e.g. simplejson -> json):
>
> try:
> from __preview__ import thing
> except ImportError:
> import thing
>
> So no need to target a very specific version of Python.
>
Yep, this is what I had in mind. And it appeared too trivial to place
it in the PEP.
Eli
More information about the Python-Dev
mailing list