A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/075837.html below:

[Python-Dev] Syntax suggestion for imports

[Python-Dev] Syntax suggestion for imports [Python-Dev] Syntax suggestion for importsDrew Perttula drewp at bigasterisk.com
Fri Jan 4 07:51:00 CET 2008
Simon Percivall wrote:
> Wouldn't a (stdlib) function suffice in the cases where this is needed?
> 
> ET = import_with_alternative("xml.etree.CElementTree", "cElementTree",  
> "elementtree.ElementTree")
> 
> It's not as elegant, but it's easier than status quo.
> 

I like that direction a lot better than the syntax proposals. This isn't 
the kind of thing that needs to get composed into bigger expressions, 
which is where clever uses of operators really shine. Here, I think the 
operators were subtracting clarity and your named function was adding 
clarity.

When I saw the OP, I actually wondered why people whose codebases are 
"filled" with the same try/except block over and over hadn't just 
written their own import_with_alternative function in the first place. 
If I wanted half my lines of code to be devoted to control flow and 
block structure, I'd write in one of those curly-brace languages :)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4