Re: updating local()

2005-10-14 Thread Bengt Richter
On Thu, 06 Oct 2005 07:15:12 -0700, Robert Kern [EMAIL PROTECTED] wrote: Flavio wrote: Ok, its not thousands, but more like dozens of variables... I am reading a large form from the web which returns a lot of values. (I am Using cherrypy) I know I could pass these variables around as:

Re: updating local()

2005-10-06 Thread Sybren Stuvel
Jp Calderone enlightened us with: If I can call functions in your process space, I've already taken over your whole program. That's true for standalone programs, but not for things like web applications, RPC calls etc. Sybren -- The problem with the world is stupidity. Not saying there should

Re: updating local()

2005-10-06 Thread Flavio
Ok, I got it! Its vey insecure, and it is not guaranteed to work. Fine. Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? Flávio -- http://mail.python.org/mailman/listinfo/python-list

Re: updating local()

2005-10-06 Thread Richard Brodie
Flavio [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? I'd lie down until I felt better. --

Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 05:55:14 -0700, Flavio [EMAIL PROTECTED] wrote: Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? I'd think twice. If on reflection I decided I really wanted to do it, I'd

Re: updating local()

2005-10-06 Thread Diez B. Roggisch
Flavio wrote: Ok, I got it! Its vey insecure, and it is not guaranteed to work. Fine. Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? use a dict or list? This is almost certainly

Re: updating local()

2005-10-06 Thread Steve Holden
Richard Brodie wrote: Flavio [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? I'd lie down until I felt better. Or

Re: updating local()

2005-10-06 Thread Flavio
I wish all my problems involved just a couple of variables, but unfortunately the real interesting problems tend to be complex... As a last resort this problem could be solved by something like this: def fun(**kw): a = 100 for k,v in kw.items(): exec('%s = %s'%(k,v)) print

Re: updating local()

2005-10-06 Thread Flavio
Ok, its not thousands, but more like dozens of variables... I am reading a large form from the web which returns a lot of values. (I am Using cherrypy) I know I could pass these variables around as: def some_function(**variables): ... some_function(**variables) but its a pain in the neck

Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 07:04:08 -0700, Flavio [EMAIL PROTECTED] wrote: I know I could pass these variables around as: def some_function(**variables): ... some_function(**variables) but its a pain in the neck to have to refer to them as variables['whatever']... dont you think? Err, no, not

Re: updating local()

2005-10-06 Thread Robert Kern
Flavio wrote: Ok, its not thousands, but more like dozens of variables... I am reading a large form from the web which returns a lot of values. (I am Using cherrypy) I know I could pass these variables around as: def some_function(**variables): ... some_function(**variables)

Re: updating local()

2005-10-06 Thread El Pitonero
Flavio wrote: I wish all my problems involved just a couple of variables, but unfortunately the real interesting problems tend to be complex... def fun(**kw): a = 100 for k,v in kw.items(): exec('%s = %s'%(k,v)) print locals() fun(**{'a':1,'b':2}) {'a': 1, 'k':

Re: updating local()

2005-10-06 Thread Grant Edwards
On 2005-10-06, Flavio [EMAIL PROTECTED] wrote: Ok, I got it! Its vey insecure, and it is not guaranteed to work. Fine. Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? Pass them in a

updating local()

2005-10-05 Thread Flavio
Hi, I heard time and again that you are not _supposed_ to update the locals dictionary. Can anyone tell me why, if the following code works, I should not do this? # # Extending Local namespace # def fun(a=1,b=2,**args): print 'locals:',locals() locals().update(args)

Re: updating local()

2005-10-05 Thread Steve Holden
Flavio wrote: Hi, I heard time and again that you are not _supposed_ to update the locals dictionary. Can anyone tell me why, if the following code works, I should not do this? # # Extending Local namespace # def fun(a=1,b=2,**args): print 'locals:',locals()

Re: updating local()

2005-10-05 Thread Sybren Stuvel
Flavio enlightened us with: Can anyone tell me why, if the following code works, I should not do this? def fun(a=1,b=2,**args): print 'locals:',locals() locals().update(args) print locals() Because it's very, very, very insecure. What would happen if someone found a way

Re: updating local()

2005-10-05 Thread Fredrik Lundh
Flavio [EMAIL PROTECTED] wrote: Can anyone tell me why, if the following code works, I should not do this? because it doesn't work: # # Extending Local namespace, now with Local namespace # def fun(a=1,b=2,**args): k=K v=V print 'locals:',locals() locals().update(args)

Re: updating local()

2005-10-05 Thread Duncan Booth
Flavio wrote: Can anyone tell me why, if the following code works, I should not do this? # # Extending Local namespace # def fun(a=1,b=2,**args): print 'locals:',locals() locals().update(args) print locals() e = {'s':3,'e':4} fun(k=10,v=32,**e) Because if all

Re: updating local()

2005-10-05 Thread Jp Calderone
On Wed, 5 Oct 2005 18:47:06 +0200, Sybren Stuvel [EMAIL PROTECTED] wrote: Flavio enlightened us with: Can anyone tell me why, if the following code works, I should not do this? def fun(a=1,b=2,**args): print 'locals:',locals() locals().update(args) print locals() Because

Re: updating local()

2005-10-05 Thread jepler
I'm surprised you found any example of 'locals().update' that worked. Here's one that doesn't work: def f(y): locals().update({'x': y}) return x print f(3) # prints 3? Jeff pgpLVe48NBWmT.pgp Description: PGP signature --