On 2020-04-10 15:44:05 -0500, Elliott Dehnbostel wrote: > *Consider the following trivial for-loop:* > > chars = "abcaaabkjzhbjacvb" > seek = {'a','b','c'} > count = 0 > for a in chars: > if a in seek: > count += 1 > > Gross. Twice nested for a simple count. > [...] > I propose the following enhancement: > > chars = "abcaaabkjzhbjacvb" > seek = {'a','b','c'} > count = 0 > for a in chars if a in seek: count += 1
I don't see much of an enhancement here. You save writing one colon and one newline here. The code itself is exactly the same. If the original was gross (I don't agree), then this is just as gross. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | h...@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list