Requiring arguments to be passed as keyword arguments

Scott.David.Daniels Scott.Daniels at Acm.Org
Wed Oct 13 00:17:30 EDT 1999


What about the fairly obvious:
      def fun(...positional..., none=None, ...keyworded...):
         if None != none: raise ArgError, "Args to fun must be keyword
args"
         # ...

It is not beautiful but it is short, clear and succinct

Michael Haggerty wrote:
> 
> Hi,
> 
> Sometimes I would like to write functions with arguments that are
> REQUIRED to be passed as keyword arguments rather than positional
> arguments.  For example, for the following function I might want the
> second parameter to be passed as a keyword parameter:




More information about the Python-list mailing list