[Tutor] [OT] Re: removing consecutive duplicates from list

dn PyTutor at DancesWithMice.info
Wed Apr 21 18:25:11 EDT 2021


On 22/04/2021 00.04, Peter Otten wrote:
> On 21/04/2021 11:56, dn via Tutor wrote:
>> On 21/04/2021 19.39, Peter Otten wrote:
> 
>>>     it = iter(items)
>>>     try:
>>>         prev = next(it)
>>>     except StopIteration: I hate you, Chris A. ;)
>>>         return
>>>     yield prev
> 
>> (not sure why we're beating-up Chris though)
> 
> https://www.python.org/dev/peps/pep-0479/
> 
> Prior to that you could write the above without the try...except.


I agree that in this simple/straight-line/non-nested situation, it seems
unnecessary. However, when chasing errors buried within the depths of
nested constructs, subtlety does seem to be the order of the day. (tools
lacking differential analysis leading to actions such as chucking the
computer out of a window)
- and worse, the prior opening of said window lacking try...except
(self-)control!

NB a few days ago, New Zealand opened a COVID-free 'travel bubble' with
most Australian states. Also, it will be ANZAC Day on Sunday,
celebrating the brotherhood (in suffering) of Australia and New Zealand
fighting for freedom. So, those of us in the North and South Islands of
this country are supposed to be getting cuddly with our Koala-cousins
over in 'West Island' - so I may be a little biased...
-- 
Regards,
=dn


More information about the Tutor mailing list