[Python-Dev] PEP 3003 - Python Language Moratorium

Nick Coghlan ncoghlan at gmail.com
Sat Nov 7 03:42:35 CET 2009


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).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list