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 :) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com