2008/6/8 David.D <[EMAIL PROTECTED]>:

>
> view.py
> =====
> def functionA(request):
>    ...
>    return ...
> def functionB(request):
>    ....
>    return ...
>
> callDict = {'functionA': functionA, 'functionB':functionB,...}
>
> def myview(request, indata):
>    func = callDict.get(indata)
>    func(request)
>
>
> indata is a string:'functionA'、'functionB'...
>
> But it doesn't work. I got TypeError: functionA() takes exactly 1
> argument (0 given)
>
> Thanks for your help.


There's something outside of what you've posted that's key here.  What you
have shown works fine in a python shell, for example:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def functionA(request):
...     print 'functionA called with request = %s' % request
...     return 0
...
>>> def functionB(request):
...     print 'functionB called with request = %s' % request
...     return 1
...
>>> callDict = {'functionA': functionA, 'functionB':functionB }
>>> def myview(request, indata):
...     func = callDict.get(indata)
...     func(request)
...
>>> myview('request1', 'functionA')
functionA called with request = request1
>>> myview('abcde', 'functionB')
functionB called with request = abcde
>>>

Karen

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to