On Tue, Jan 12, 2016 at 10:12 AM, Terry Reedy <tjre...@udel.edu> wrote: > Using the values views at intended (as an iterable): > >>>> dv = d.values() >>>> next(iter(dv)) > 1
Good coding practice also dictates that whenever next is called, the potential StopIteration exception must be caught unless it is clearly intended to be propagated up to some generator. So more fully, this should be something like: dv = iter(d.values()) try: next(dv) except StopIteration: raise IndexError("d is empty") At which point it may be desirable to extract that into a utility function. -- https://mail.python.org/mailman/listinfo/python-list