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

Re: elif alternative

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 12:38 PM, gert gert.cuyk...@gmail.com 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

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

Re: elif alternative

2009-09-17 Thread gert
On Sep 17, 9:48 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Sep 17, 2009 at 12:38 PM, gert gert.cuyk...@gmail.com 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

Re: elif alternative

2009-09-17 Thread r
On Sep 17, 2:38 pm, gert gert.cuyk...@gmail.com 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 =

Re: elif alternative

2009-09-17 Thread gert
On Sep 17, 9:48 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Sep 17, 2009 at 12:38 PM, gert gert.cuyk...@gmail.com 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

Re: elif alternative

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

Re: elif alternative

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 3:09 PM, gert gert.cuyk...@gmail.com wrote: On Sep 17, 9:48 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Sep 17, 2009 at 12:38 PM, gert gert.cuyk...@gmail.com wrote: Can anybody show me a better looking alternative for this elif structure ? Use a dictionary

Re: elif alternative

2009-09-17 Thread gert
On Sep 18, 12:12 am, gert gert.cuyk...@gmail.com wrote: On Sep 18, 12:09 am, gert gert.cuyk...@gmail.com wrote: On Sep 17, 9:48 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Sep 17, 2009 at 12:38 PM, gert gert.cuyk...@gmail.com wrote: Can anybody show me a better looking