[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    Re: [Python-Dev] PEP 408 -- Standard library __preview__ package
From:       Michael Foord <fuzzyman () voidspace ! org ! uk>
Date:       2012-01-27 15:39:44
Message-ID: 4F22C540.3030007 () voidspace ! org ! uk
[Download RAW message or body]

On 27/01/2012 15:35, Matt Joiner wrote:
>> 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.
> I think this is suboptimal, having to guess where modules are located,
> you end up with this in every module:
>
> try:
>      import cjson as json
> except ImportError:
>     try:
>         import simplejson as json
>    except ImportError:
>        import json as json

It's trivial to wrap in a function though - or do the import in one 
place and then import the package from there.

Michael

> Perhaps the versioned import stuff could be implemented (whatever the
> syntax may be), in order that something like this can be done instead:
>
> import regex('__preview__')
> import regex('3.4')
>
> Where clearly the __preview__ version makes no guarantees about
> interface or implementation whatsoever.
>
> etc.
>


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic