"Peter J. Holzer" <hjp-pyt...@hjp.at> writes: > On 2021-08-29 10:04:47 +0100, Barry 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? >> >> Surely the choice is made in most cases by the algorithm? > > The context here is an introductory course for Python. So there is not > "the algorithm", there are all the algorithms that a novice is likely > to encounter. > > For me it makes absolute sense to base the contents of the course on > popularity. Constructs which a novice programmer is very likely to use > or encounter in other people's code should be covered more thoroughly > than constructs that will be used only rarely. Some are so rare that > they can be safely omitted. The while loop is certainly not in that > category, but it probably makes sense to spend less time on it than on > the for loop.
``A man after my own heart.'' -- https://mail.python.org/mailman/listinfo/python-list