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:
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
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
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.
--
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
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
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
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
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
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
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)
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':
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
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)
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()
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
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)
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
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
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
--
20 matches
Mail list logo