Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 2:35 am, gert wrote: > On Sep 18, 2:11 am, Chris Rebert wrote: > > > > > On Thu, Sep 17, 2009 at 5:03 PM, gert wrote: > > > > > > > So far i have this > > >http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointme... > > > > I have 3 problems left Any_GID, Everybody_no_GI

Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 2:11 am, Chris Rebert wrote: > On Thu, Sep 17, 2009 at 5:03 PM, gert wrote: > > > > > So far i have this > >http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointme... > > > I have 3 problems left Any_GID, Everybody_no_GID, > > Just add entries to the dictionary with the

Re: elif alternative

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 5:03 PM, gert wrote: > So far i have this > http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointment.wsgi > > I have 3 problems left Any_GID, Everybody_no_GID, Just add entries to the dictionary with the same function as value but all permutations of GID as

Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 12:18 am, gert wrote: > On Sep 18, 12:12 am, gert wrote: > > > > > On Sep 18, 12:09 am, gert wrote: > > > > On Sep 17, 9:48 pm, Chris Rebert wrote: > > > > > On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > > > > > Can anybody show me a better looking alternative for this elif > > >

Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 12:12 am, gert wrote: > On Sep 18, 12:09 am, gert wrote: > > > > > On Sep 17, 9:48 pm, Chris Rebert wrote: > > > > On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > > > > Can anybody show me a better looking alternative for this elif > > > > structure ? > > > > Use a dictionary with fu

Re: elif alternative

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 3:09 PM, gert wrote: > On Sep 17, 9:48 pm, Chris Rebert wrote: >> On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: >> > Can anybody show me a better looking alternative for this elif >> > structure ? >> >> Use a dictionary with functions as values. For example: >> >> #untest

Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 12:09 am, gert wrote: > On Sep 17, 9:48 pm, Chris Rebert wrote: > > > > > On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > > > Can anybody show me a better looking alternative for this elif > > > structure ? > > > Use a dictionary with functions as values. For example: > > > #untested

Re: elif alternative

2009-09-17 Thread gert
On Sep 17, 9:48 pm, Chris Rebert wrote: > On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > > Can anybody show me a better looking alternative for this elif > > structure ? > > Use a dictionary with functions as values. For example: > > #untested obviously > def admin_remove(db, v, gid): >     db.e

Re: elif alternative

2009-09-17 Thread r
On Sep 17, 2:38 pm, gert wrote: > Can anybody show me a better looking alternative for this elif > structure ? > > http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointme... For starters assign v['cmd'] to a variable instead of looking it up every time! cmd = v['cmd'] if cmd == ..

Re: elif alternative

2009-09-17 Thread gert
On Sep 17, 9:48 pm, Chris Rebert wrote: > On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > > Can anybody show me a better looking alternative for this elif > > structure ? > > Use a dictionary with functions as values. For example: > > #untested obviously > def admin_remove(db, v, gid): >     db.e

Re: elif alternative

2009-09-17 Thread MRAB
gert wrote: Can anybody show me a better looking alternative for this elif structure ? http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointment.wsgi Where you have cascaded ifs based on a single value, one alternative is to use a dict where the test value is the key and function

Re: elif alternative

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 12:38 PM, gert wrote: > Can anybody show me a better looking alternative for this elif > structure ? Use a dictionary with functions as values. For example: #untested obviously def admin_remove(db, v, gid): db.execute("DELETE FROM appointments WHERE aid=?",(v['aid'],)

elif alternative

2009-09-17 Thread gert
Can anybody show me a better looking alternative for this elif structure ? http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/appointment.wsgi -- http://mail.python.org/mailman/listinfo/python-list