Rather than using ```len()```, you can treat the sequence as a boolean e.g. use ```if dim_coords``` as an empty sequence is regarded as False and a sequence with one or more elements is True.