Author tim.peters
Recipients Serge Anuchin, mark.dickinson, pitrou, r.david.murray, rhettinger, serhiy.storchaka, skrah, steven.daprano, tim.peters, vstinner
Date 2015-07-12.19:36:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I have a question about this new snippet in choice():

+        if i == n and n > 0:
+            i = n - 1

What's the purpose of the "and n > 0" clause?  Without it, if i == n == 0 then i will be set to -1, which is just as good as 0 for the purpose of raising IndexError (seq[any_int] raises IndexError when seq is empty).
Date User Action Args
2015-07-12 19:36:54tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, pitrou, vstinner, steven.daprano, r.david.murray, skrah, serhiy.storchaka, Serge Anuchin
2015-07-12 19:36:54tim.peterssetmessageid: <>
2015-07-12 19:36:54tim.peterslinkissue24567 messages
2015-07-12 19:36:54tim.peterscreate