[Numpy-discussion] exec: bad practice?

Alan G Isaac aisaac@american....
Tue Sep 15 07:34:35 CDT 2009

On 9/15/2009 7:07 AM, Sebastien Binet wrote:
> usage of the exec statement is usually frown upon and can be side stepped.
> e.g:
> for m in meat:
>      for c in cut:
>        locals()['consumed_%s_%s' % (m,c)] = some_array

Additionally, name construction can be pointless.

info = dict()
for pr in itertools.product(meat, cut):
	info[pr] = f(pr)

Alan Isaac

More information about the NumPy-Discussion mailing list