Python/getargs/va_and_kw

Source   Edit  

Procs

proc PyArg_VaParseTupleAndKeywords(funcname: NimNode; args: NimNode;
                                   keywords: NimNode;
                                   kwOnlyList: openArray[string]; vargs: NimNode): NimNode {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc PyArg_VaParseTupleAndKeywordsAs(funcname: NimNode; args: NimNode;
                                     keywords: NimNode;
                                     kwOnlyList: openArray[string];
                                     vargs: NimNode): NimNode {....raises: [],
    tags: [], forbids: [].}

Example:

runnableExamples:
  retIfExc PyArg_ParseTupleAndKeywordsAs(args, kwargs,
    ["start", "stop"],
    x, start=0, stop=100
  )
Source   Edit  

Macros

macro PyArg_ParseTupleAndKeywords(funcname: string; args: openArray[PyObject];
                                  keywords: PyDictObject;
                                  kwOnlyList: static openArray[string];
                                  vargs: varargs[typed]): PyBaseErrorObject
vargs can be, e.g.: v: int or v = 1, also pragma like convertVia is supported Source   Edit  
macro PyArg_ParseTupleAndKeywordsAs(funcname: string; args: openArray[PyObject];
                                    keywords: PyDictObject;
                                    kwOnlyList: static openArray[string];
                                    vargs: varargs[untyped]): PyBaseErrorObject
Source   Edit