Works like a charm, thank you very much!
On Jun 12, 2:09 am, Johannes Dollinger
<[EMAIL PROTECTED]> wrote:
> You are looking for setattr():http://docs.python.org/lib/built-in-
> funcs.html#l2h-66
>
> for attr in ('groupon', 'companyon', 'addressfirst', 'extendnames',
> 'clubfieldson'):
>
You are looking for setattr(): http://docs.python.org/lib/built-in-
funcs.html#l2h-66
for attr in ('groupon', 'companyon', 'addressfirst', 'extendnames',
'clubfieldson'):
setattr(settings, attr, attr in data)
Am 12.06.2008 um 00:48 schrieb Wim Feijen:
>
> Thanks Russell!
>
> I suppose
Thanks Russell!
I suppose the code I want to get looks like:
settings = Settings.objects.get(owner=userid)
for switchable in ['groupon', 'companyon', 'addressfirst',
'extendnames', 'clubfieldson']:
if switchable in data:
settings._meta.get_field(switchable). = True
else:
On Tue, Jun 10, 2008 at 9:25 PM, Wim Feijen <[EMAIL PROTECTED]> wrote:
>
> Coding happily away...
>
> And wondering, can I write better code, using a loop, perhaps? In
> other words: can I set settings.groupon while using a variable in
> stead of groupon?
>
> Thanks for any recommendations you
Coding happily away...
And wondering, can I write better code, using a loop, perhaps? In
other words: can I set settings.groupon while using a variable in
stead of groupon?
Thanks for any recommendations you are willing to make!
Wim Feijen
---
My not-too-pretty code:
settings =
5 matches
Mail list logo