Need advice on distributing small module

Nick Craig-Wood nick at craig-wood.com
Sat May 16 06:30:01 EDT 2009


kj <socyl at 987jk.com.invalid> wrote:
>  The module has only one non-standard dependency, described by the
>  following code:
> 
>  if sys.version_info[:2] >= (2, 6):
>      import json
>  else:
>      import simplejson as json

I think

try:
    import json
except ImportError:
    import simplejson as json

Is more pythonic...  You aren't relying on what came with particular
python versions which may not be true in jython/ironpython/etc.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list