Terry Reedy wrote: [...] > try: > item = seq[n] > except IndexError > do_without_item() > else: > process(item) > > item = seq[n:n+1] > if item: > process(item) > else: > do_without_item() > > Many prefer the second.
And they'll prefer it even more when they realize the entire ELSE clause of your latter example is superfluous. But there are many usages where the conditional logic is not needed at all. Sometimes you don't care what you get back from a slice. Yep, even when the slice is a null string. -- https://mail.python.org/mailman/listinfo/python-list