On Oct 13, 12:23 pm, Mick Krippendorf wrote:
> Carl Banks schrieb:
>
> > Lemme guess.
>
> > You tried this at the interactive prompt and concluded it worked in
> > general, right?
>
> Yes. Thank you for enlighten me.
>
> > One of these days we're going to have a thread like this where no one
> > m
Carl Banks schrieb:
> Lemme guess.
>
> You tried this at the interactive prompt and concluded it worked in
> general, right?
Yes. Thank you for enlighten me.
> One of these days we're going to have a thread like this where no one
> makes this mistake. Don't know when, but one day it will happen
On Tue, 13 Oct 2009 17:05:03 +0100, Chris Withers wrote:
[snip]
> - what is so wrong with wanting to set a variable in the local namespace
> based on a name stored in a variable?
I'm not sure it's "so wrong" that one should never, ever do
it, but it *does* blur the boundary between the program an
Mick Krippendorf wrote:
Yes, and, uh, yes. "locals()['foo'] = bar" works in that it does the
same thing as "foo = bar". So why don't you write that instead?
Mick.
I wouldn't expect it to do the same thing at all, and it doesn't, at
least not in Python 2.6.2. It may store the "bar" som
On Oct 13, 9:39 am, Mick Krippendorf wrote:
> Yes, and, uh, yes. "locals()['foo'] = bar" works in that it does the
> same thing as "foo = bar". So why don't you write that instead?
Lemme guess.
You tried this at the interactive prompt and concluded it worked in
general, right?
Even though when
Chris Withers wrote:
> - what is so wrong with wanting to set a variable in the local namespace
> based on a name stored in a variable?
What's wrong is that no other statement using the local name space can know
what that name might be. It's a documented fact that changing the locals()
diction
On Oct 13, 9:05 am, Chris Withers wrote:
> Hi All,
>
> Say I have a piece of code like this:
>
> mname = model.__name__
> fname = mname+'_order'
> value = request.GET.get('order')
> if value:
> request.session[fname]=value
> else:
>
Chris Withers wrote:
> Now, if I want to do *exactly* the same thing with a variable named
> 'sort', I have to copy and paste the above code or do something hacky
> like have a dict called "vars" and manipulate that, or factor the above
> into a function and take the hit on the extra function
Hello.
Chris Withers schrieb:
> mname = model.__name__
> fname = mname+'_order'
> value = request.GET.get('order')
> if value:
> request.session[fname]=value
> else:
> value = request.session.get(
> fname,
>
En Tue, 13 Oct 2009 13:05:03 -0300, Chris Withers
escribió:
What I'd be looking for is something like:
locals()[name]=value
...or, say:
setattr(,name,value)
Now, I got horribly flamed for daring to be so heretical as to suggest
this might be a desirable thing in #python, so I thought I'
Hi All,
Say I have a piece of code like this:
mname = model.__name__
fname = mname+'_order'
value = request.GET.get('order')
if value:
request.session[fname]=value
else:
value = request.session.get(
fname,
11 matches
Mail list logo