Re: implicit variable declaration and access

2005-06-16 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Christopher Subich <[EMAIL PROTECTED]> wrote: . . . >Out of curiosity, where would you classify interpreters for secondary >app-specific programming languages? Specifically, mud-client stored

Re: implicit variable declaration and access

2005-06-15 Thread Tom Anderson
On Tue, 14 Jun 2005, Scott David Daniels wrote: > Tom Anderson wrote: >> ... If it's not, try: >> x = "myVarName" >> y = "myVarValue" >> locals()[x] = y > > Sorry, this works with globals(), but not with locals(). Oh, weird. It works when i tried it. Aaaah, i only tried it at the interactive pro

Re: implicit variable declaration and access

2005-06-14 Thread Ali Razavi
Steven D'Aprano wrote: > On Mon, 13 Jun 2005 12:18:31 -0400, Ali Razavi wrote: > > >>Is there any reflective facility in python >>that I can use to define a variable with a >>name stored in another variable ? >>like I have : >>x = "myVarName" >> >>what can I do to declare a new variable with the

Re: implicit variable declaration and access

2005-06-14 Thread Scott David Daniels
Tom Anderson wrote: > ... If it's not, try: > x = "myVarName" > y = "myVarValue" > locals()[x] = y Sorry, this works with globals(), but not with locals(). There isn't a simple way to fiddle the locals (the number is determined when the function is built). I do, however, agree with you about what

Re: implicit variable declaration and access

2005-06-14 Thread Tom Anderson
On Mon, 13 Jun 2005, Ali Razavi wrote: > Tom Anderson wrote: >> On Mon, 13 Jun 2005, Ali Razavi wrote: >> >>> Is there any reflective facility in python that I can use to define a >>> variable with a name stored in another variable ? >>> >>> like I have : >>> x = "myVarName" >>> >>> what can I

Re: implicit variable declaration and access

2005-06-13 Thread Christopher Subich
Cameron Laird wrote: > cleaner algorithm somewhere in the neighborhood. In general, > "application-level" programming doesn't need exec() and such. > > PyPy and debugger writers and you other "systems" programmers > already know who you are. Out of curiosity, where would you classify interprete

Re: implicit variable declaration and access

2005-06-13 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Ali Razavi <[EMAIL PROTECTED]> wrote: >Tom Anderson wrote: >> On Mon, 13 Jun 2005, Ali Razavi wrote: >> >>> Is there any reflective facility in python that I can use to define a >>> variable with a name stored in another variable ? .

Re: implicit variable declaration and access

2005-06-13 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Peter Dembinski <[EMAIL PROTECTED]> wrote: >Benji York <[EMAIL PROTECTED]> writes: > >[snap] > >>> code = x + '= 0' >>> exec(code) >> >> You should generally stay away from exec for lots of reasons. > >Code 'refactorizability' is one of them. There's an affirmative

Re: implicit variable declaration and access

2005-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2005 12:18:31 -0400, Ali Razavi wrote: > Is there any reflective facility in python > that I can use to define a variable with a > name stored in another variable ? > like I have : > x = "myVarName" > > what can I do to declare a new variable with the name of the string > stored in

Re: implicit variable declaration and access

2005-06-13 Thread Tom Anderson
On Mon, 13 Jun 2005, Peter Dembinski wrote: > Tom Anderson <[EMAIL PROTECTED]> writes: > > [snap] > >> The MAtrix had evarything in it: guns, a juimping off teh walls, flying >> guns, a bullet tiem, evil computar machenes, numbers that flew, flying >> gun bullets in slowar motian, juimping into

Re: implicit variable declaration and access

2005-06-13 Thread Ali Razavi
Tom Anderson wrote: > On Mon, 13 Jun 2005, Ali Razavi wrote: > >> Is there any reflective facility in python that I can use to define a >> variable with a name stored in another variable ? >> >> like I have : >> x = "myVarName" >> >> what can I do to declare a new variable with the name of the st

Re: implicit variable declaration and access

2005-06-13 Thread Peter Dembinski
Tom Anderson <[EMAIL PROTECTED]> writes: [snap] > The MAtrix had evarything in it: guns, a juimping off teh walls, > flying guns, a bullet tiem, evil computar machenes, numbers that > flew, flying gun bullets in slowar motian, juimping into a gun, dead > police men, computar hackeing, Kevin Mitni

Re: implicit variable declaration and access

2005-06-13 Thread Tom Anderson
On Mon, 13 Jun 2005, Ali Razavi wrote: > Is there any reflective facility in python that I can use to define a > variable with a name stored in another variable ? > > like I have : > x = "myVarName" > > what can I do to declare a new variable with the name of the string > stored in x. And how ca

Re: implicit variable declaration and access

2005-06-13 Thread Peter Dembinski
Benji York <[EMAIL PROTECTED]> writes: [snap] >> code = x + '= 0' >> exec(code) > > You should generally stay away from exec for lots of reasons. Code 'refactorizability' is one of them. -- http://mail.python.org/mailman/listinfo/python-list

Re: implicit variable declaration and access

2005-06-13 Thread Benji York
Ali Razavi wrote: > Ali Razavi wrote: > >>Is there any reflective facility in python >>that I can use to define a variable with a >>name stored in another variable ? > Got it! use higher order functions like Lisp! No, you use higher order functions like Python. :) > code = x + '= 0' > exec(cod

Re: implicit variable declaration and access

2005-06-13 Thread Ali Razavi
Ali Razavi wrote: > Is there any reflective facility in python > that I can use to define a variable with a > name stored in another variable ? > like I have : > x = "myVarName" > > what can I do to declare a new variable with the name of the string > stored in x. And how can I access that implici