Is there a better way of doing this?
Paul Rubin
http
Fri Mar 6 08:18:00 EST 2009
Chris Rebert <clp2 at rebertia.com> writes:
> for i in range(len(fap)):
> selected_population.append(choice(rw))
"for i in range(len(something))" is a bit of a code smell. You could
instead say:
selected_population.extend(choice(rw) for x in fap)
The unused "x" is also a slight code smell, but the most obvious cures
involve using the itertools module in ways that are worse than the disease.
More information about the Python-list
mailing list