[Python-Dev] PEP 3003 - Python Language Moratorium

Guido van Rossum guido at python.org
Sat Nov 7 04:16:10 CET 2009


On Fri, Nov 6, 2009 at 6:42 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Georg Brandl wrote:
>> Guido van Rossum schrieb:
>>
>>> Actually, I think Dirkjan has a point. I'm not sure that we need
>>> another moratorium (that's a rather dramatic kind of decision which
>>> should be very rare indeed) but I do agree that deprecations are often
>>> more of a pain than they're worth.
>>>
>>> For example, take the deprecation of the md5 and sha modules in Python
>>> 2.6. They make it a bit of a pain to write code that *cleanly*
>>> supports Python 2.4 (doesn't have hashlib) through 2.6 (warns when
>>> importing md5 instead of hashlib). You can silence the warning, but
>>> that is in itself not particularly clean, and users really hate having
>>> the warnings.
>>
>> Trying to import hashlib and importing md5 on ImportError isn't *too* unclean,
>> is it?
>
> Having had to do this myself a few times, I was always a little
> surprised the "import-or" idea [1] didn't get more support the last time
> it was proposed.
>
> Ah well, don't need to worry about that idea again until 3.4 or so :)
>
> Cheers,
> Nick
>
> P.S. For anyone unfamiliar with it, "import-or" was a suggestion made
> around the time xml.etree was added to the standard library to provide a
> "import x or y as z" shorthand for:
>  try:
>    import x as z
>  except ImportError:
>    import y as z
>
> (allowing "from a or b import c" was also part of the suggestion, as was
> allowing multiple "or" elements in a single import request)
>
> Support for the idea was lukewarm at best, hostile at worst (hence the
> lack of PEP).

I'm still -1 on that -- while it may sound like a good shorthand if
you have to deal with this, it's IMO pretty mysterious if you
encounter this and don't already happen to know what it means. Also,
it makes no sense without the 'as' clause which makes it a bit
awkward. (I could probably come up with a few more arguments against
it, just trying to hint that I'm personally less than lukewarm. :-)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list