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