En Tue, 19 May 2009 14:06:04 -0300, Gökhan SEVER gokhanse...@gmail.com
escribió:
I will make double sure myself while using locals() to end up with valid
identifiers.
I would ask myself why I'm using locals() in the first place.
--
Gabriel Genellina
--
Hello,
I use local() because I read a file which has many consecutive variables in
it. Like shown below: (I use numpy's txt reading function)
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
On Fri, May 22, 2009 at 10:27 AM, Gökhan SEVER gokhanse...@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
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.
Gökhan
On Fri, May 22, 2009
Top-posting corrected.
On Fri, 2009-05-22 at 10:00 -0500, Gökhan SEVER wrote:
On Fri, May 22, 2009 at 9:43 AM, David Robinow drobi...@gmail.com
wrote:
On Fri, May 22, 2009 at 10:27 AM, Gökhan SEVER
gokhanse...@gmail.com wrote:
...
serialc =
On Fri, May 22, 2009 at 11:00 AM, Gökhan SEVER gokhanse...@gmail.com 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,
Sorry for breaking threading, the original post is not being carried by
my ISP.
On Tue, 19 May 2009, Gökhan SEVER wrote:
Hello,
Could you please explain why locals() allow me to create variables that
are not legal in Python syntax. Example: locals()['1abc'] = 55. Calling
of 1abc results
Thank you all for great explanation on this subject. Maybe a few sentences
from these conversations could be added to locals() documentation.
I will make double sure myself while using locals() to end up with valid
identifiers.
Gökhan
On Tue, May 19, 2009 at 1:06 AM, Steven D'Aprano
Hello,
Could you please explain why locals() allow me to create variables that are
not legal in Python syntax. Example: locals()['1abc'] = 55. Calling of 1abc
results with a syntax error. Shouldn't it be better to raise an error during
the variable creation time?
Thank you
Gökhan
--
On Tue, 19 May 2009, Gökhan SEVER wrote:
Hello,
Could you please explain why locals() allow me to create variables that are
not legal in Python syntax. Example: locals()['1abc'] = 55. Calling of 1abc
results with a syntax error. Shouldn't it be better to raise an error
during the variable
Gökhan SEVER wrote:
Hello,
Could you please explain why locals() allow me to create variables that
are not legal in Python syntax.
It doesn't.
Example: locals()['1abc'] = 55. Calling
of 1abc results with a syntax error.
Within a function, locals() is a persistemt dictionary copy of the
11 matches
Mail list logo