On Wed, Mar 5, 2008 at 5:33 AM, Neal Becker <[EMAIL PROTECTED]> wrote: > It is a bit unfortunate that slicing has a singularity. > > samples_to_trim = (some calculation yielding an integer >= 0) > > > trimmed_vector = vector[:-samples_to_trim] if samples_to_trim != 0 else > vector[:] > > A bit unfortunate that the case of samples_to_trim == 0 has to be handled > differently. > > I don't really see any solution to this.
Just transform the problem away. If you can guarantee that samples_to_trim is <= len(vector), then it's trivial: trimmed_vector = vector[:len(vector) - samples_to_trim] If not, it gets more complicated, but you can wrap the upper bound in a max(0, ...). -- Michael Urman _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com