[Python-Dev] PEP 408 -- Standard library __preview__ package
Philippe Fremy
phil at freehackers.org
Fri Jan 27 17:09:08 CET 2012
On 27/01/2012 16:25, Michael Foord wrote:
> On 27/01/2012 14:37, Philippe Fremy wrote:
>> Hi,
>>
>> A small comment from a user perspective.
>>
>> Since a package in preview is strongly linked to a given version of
>> Python, any program taking advantage of it becomes strongly specific to
>> a given version of Python.
>>
>> Such programs will of course break for any upgrade or downgrade of
>> python version. To make the reason for the breakage more explicit, I
>> believe that the PEP should provide examples of correct versionned usage
>> of the module.
>>
>> 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.
>
According to the PEP, the interface may change betweeen __preview__ and
final inclusion in stdlib. It would be unwise as a developer to assume
that a program written for the preview version will work correctly in
the stdlib version, wouldn't it ?
I would use your "normal" incantation only after checking that no
significant API change have occured after stdlib integration.
By the way, if as Antoine suggests, the package remain available in
__preview__ even after it's accepted in the stdlib, how is the user
supposed to deal with possible API changes ?
cheers,
Philippe
More information about the Python-Dev
mailing list