Question about locals()

David Robinow drobinow at gmail.com
Fri May 22 10:43:01 EDT 2009


On Fri, May 22, 2009 at 10:27 AM, Gökhan SEVER <gokhansever at gmail.com> wrote:
...
> serialc = np.loadtxt(sys.argv[1], skiprows=skiprows).T
> for i in range(20):
>     locals()['serialc_bin' + str(i+1)] = serialc[i+4]
>
> I don't know easier way than using locals() to construct variable-like
> identities in my program.

I don't either.  I also don't know why you feel you need to construct
variable-like identities.
Why is:
  serialc_bin1
better than
  serialc_bin[0]
or, for that matter,
 serialc[4]

???



More information about the Python-list mailing list