Alan Gauld <alan.ga...@btinternet.com> writes: > On 05/02/16 02:03, noopy via Tutor wrote: > > > def permutations(items): > > n = len(items) > > if n==0: yield [] > > else: > > I assume this bit is clear enough?
I think it would be clearer without the needless opaque name ‘n’. Better:: def permutations(items): if not items: # ‘items’ is empty (or is not a container). yield [] else: for i in range(len(items)): … Binding a name that is used exactly once should be done only if the name clarifies the purpose. An opaque name like ‘n’ is not helpful. -- \ “Why doesn't Python warn that it's not 100% perfect? Are people | `\ just supposed to “know” this, magically?” —Mitya Sirenef, | _o__) comp.lang.python, 2012-12-27 | Ben Finney _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor