apply for keywords

Curtis Jensen cjensen at bioeng.ucsd.edu
Wed Jul 11 13:15:38 EDT 2001


Can you use "apply" to pass keywords?  If so, what is the syntax?

ie:
Python 1.5.2 (#4, Sep  5 2000, 10:29:12) [C] on irix646
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> def foo( bar = None ):
...   if bar != None:
...     print 'ok'
...   else:
...     print 'not ok'
... 
>>> apply( foo, [bar = 1] )
  File "<stdin>", line 1
    apply( foo, [bar = 1] )
                     ^
SyntaxError: invalid syntax
>>> apply( foo, bar = 1 )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: this function takes no keyword arguments
>>> apply(foo, (bar = 1) )
  File "<stdin>", line 1
    apply(foo, (bar = 1) )
                    ^
SyntaxError: invalid syntax
>>> 

-- 
Curtis Jensen
cjensen at bioeng.ucsd.edu
http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451



More information about the Python-list mailing list