on the popularity of loops while and for
Hope Rouselle
hrouselle at jevedi.com
Thu Sep 2 09:27:15 EDT 2021
Barry <barry at barrys-emacs.org> writes:
>> On 28 Aug 2021, at 22:42, Hope Rouselle <hrouselle at jevedi.com> wrote:
>>
>> I'd like get a statistic of how often each loop is used in practice.
>>
>> I was trying to take a look at the Python's standard libraries --- those
>> included in a standard installation of Python 3.9.6, say --- to see
>> which loops are more often used among while and for loops. Of course,
>> since English use the preposition ``for'' a lot, that makes my life
>> harder. Removing comments is easy, but removing strings is harder. So
>> I don't know yet what I'll do.
>>
>> Have you guys ever measured something like that in a casual or serious
>> way? I'd love to know. Thank you!
>
> I am interesting in why you think that choice of while vs. for is
> about popularity?
Perhaps you think my choice of "popular" had a special judgement about
it. Let's define "popular" in the way that I used it.
--8<---------------cut here---------------start------------->8---
Definition. We say x is more popular than y if x appears more times
relative to y when considered in a sample.
Example. For loops are more popular than while loops in a certain
sample because they appeared 17 times compared to 5 times the while loop
appeared.
--8<---------------cut here---------------end--------------->8---
So it's just a numeric comparison.
[...]
More information about the Python-list
mailing list