On Thu, 2009-02-19 at 16:35 -0500, Alex Gaynor wrote: > > > On Thu, Feb 19, 2009 at 4:17 PM, Nicolas Steinmetz > <nsteinm...@gmail.com> wrote: > > Nicolas Steinmetz a écrit : > > > > Thanks for the answer. I'll implement the 2nd method, which > makes far > > more sens than my first "harsh and straight away" > approach ;-) > > > Solution was finally : > > try: > tips ={'google': google(request.POST['search'], > number), > 'googlefr': googlefr(request.POST['search'], > number), > 'dmoz': dmoz(request.POST['search'], number), > 'ask': ask(request.POST['search'], number), > 'yahoo': yahoo(request.POST['search'], number), > 'msn': msn(request.POST['search'], number), > 'excite': excite(request.POST['search'], > number)}.get(engine) > except KeyError: > tips=google(request.POST['search'], number) > > > Thanks, > > Nicolas > > > > > > Remember when you do that it's going to call every single one of those > functions regardless of which engine is actually selected.
Yeah, really, don't do that. Retrieve the callable that you want and *then* call it by passing in the correct parameters. It will also make the code look a lot neater, since you'll only need to type out request.POST["search"] and "number" once, instead of N times. Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---