trapping errors in function call syntax
Carsten Haese
carsten at uniqsys.com
Mon Feb 13 14:22:22 EST 2006
On Mon, 2006-02-13 at 14:13, Avi Kak wrote:
> Hello:
>
> Suppose I write a function that I want to be called
> with ONLY keyword argumnts, how do I raise an
> exception should the function get called with
> what look like position-specfic arguments?
>
> Any help would be appreciated.
Something like this should do the trick:
def f(*args, **kwargs):
if args: raise TypeError, "Please use keyword arguments."
...
-Carsten
More information about the Python-list
mailing list