This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <1436729814.63.0.700149795099.issue24567@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
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: <1436729814.63.0.700149795099.issue24567@psf.upfronthosting.co.za>
2015-07-12 19:36:54tim.peterslinkissue24567 messages
2015-07-12 19:36:54tim.peterscreate