[Python-ideas] "maybe import"?

Andrew Barnert abarnert at yahoo.com
Fri Dec 27 13:23:39 CET 2013


On Dec 27, 2013, at 1:34, Amber Yust <amber.yust at gmail.com> wrote:

> On Fri Dec 27 2013 at 12:33:11 AM, Guido van Rossum <guido at python.org> wrote:
>> We shouldn't encourage optional dependencies. They often make code harder to reason about or harder to read.
> 
> Is there a better alternative for utilizing functionality that may vary in availability from platform to platform?

The only way to use this would be to then continually check "if foo:" all throughout your module, to use it if present and do something else if not. I suspect that is a bigger readability/comprehensibility problem than the extra lines of code up top.

And in many cases, once you reorganize your code to solve that problem, this one goes away as well.

>  
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131227/2c78ee9d/attachment.html>


More information about the Python-ideas mailing list