[Python-Dev] PEP 408 -- Standard library __preview__ package

Steven D'Aprano steve at pearwood.info
Sat Feb 4 00:18:37 CET 2012


Chris Withers wrote:

> Every time I see things like the following I cry a little inside:
> 
> try:
>   try:
>     from py2stdliblocation import FooBar as Foo
>   except ImportError:
>     from py3stdliblocation import foo as Foo
> except ImportError:
>   from pypilocation import Foo


The syntax is inelegant, but the concept is straightforward and simple and not 
worth tears.

"I need a thing called Foo, which can be found here, or here, or here. Use the 
first one found."

In principle this is not terribly different from the idea of a search PATH 
when looking for an executable, except the executable can be found under 
different names as well as different locations.


> Now we're talking about having to add __preview__ into that mix too?

As I understand it, Guido nixed that idea. (Or did I imagine that?) Preview 
modules will be just added to the std lib as normal, and you have to read the 
docs to find out they're preview.



-- 
Steven



More information about the Python-Dev mailing list