Question about locals()

David Robinow drobinow at
Fri May 22 11:52:48 EDT 2009

On Fri, May 22, 2009 at 11:00 AM, Gökhan SEVER <gokhansever at> wrote:
> Because in this case serialc is an numpy array. Since loadtxt returns a
> numpy-array. Furthermore
> locals()['serialc_bin' + str(i+1)]  creates a dictionary key (that's what I
> use the term "variable-like") serialc_bin1, serialc_bin2, ... not
> serialc_bin[0] with indexes.

A name (or variable as you call it) is not a dictionary key. The
contents of the name may be.
A list can not be a dictionary key. However, a list element can be (or
not, if the element itself is mutable)
You gain nothing by creating all these names.

More information about the Python-list mailing list