From: Cherry, J. (NIH/NLM/N. [E] <jc...@nc...> - 2013-08-08 18:06:28
|
Also, you could write your own Python function that figures out what call to make to the SWIG-generated function. Josh -----Original Message----- From: William S Fulton [mailto:ws...@fu...] Sent: Thursday, August 08, 2013 1:37 PM To: Olivier Voyer Cc: <swi...@li...> Subject: Re: [Swig-user] Python keyword arguments and overloaded functions http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_default_args states "SWIG is unable to support kwargs when wrapping overloaded methods". I think this is because of potential ambiguities as to which method should be called. However, you can use kwargs for a method with default parameters as there is then no ambiguity as to which method to call. Sometimes you can rewrite your overloaded C++ methods as one single method with default parameters, so consider that as a workaround. William On 23/07/13 16:56, Olivier Voyer wrote: > I would be interested by the answer as well. Let me know if you find a > way, > > Le 2013-07-18 à 09:06, Bradley Lowekamp <blo...@ma...> a écrit : > >> Hello, >> >> I am using swig to generate interfaces from my header files with some type map guidance. For our swig generation of python binding I am passing the "-keyword" argument. >> >> I have some overloaded procedural methods[1] like the following: >> >> Image Resample ( const Image& image1, Transform transform = >> itk::simple::Transform(), InterpolatorEnum interpolator = >> itk::simple::sitkLinear, double defaultPixelValue = 0.0 ); Image Resample ( const Image& image1, const Image& referenceImage, Transform transform = itk::simple::Transform(), InterpolatorEnum interpolator = itk::simple::sitkLinear, double defaultPixelValue = 0.0 ); .... >> >> I can't use keyword arguments with these methods. Here is what I get: >> >> In [1]: import SimpleITK as sitk >> >> In [2]: img = sitk.Image() >> >> In [3]: sitk.Resample(img, defaultPixelValue=1) >> --------------------------------------------------------------------------- >> TypeError Traceback (most recent call last) >> <ipython-input-3-8a2b278d5bba> in <module>() >> ----> 1 sitk.Resample(img, defaultPixelValue=1) >> >> TypeError: Resample() got an unexpected keyword argument 'defaultPixelValue' >> >> Is this a bug or a missing feature? I very much would like this ability. we have a number of procedural methods with a large number of parameters which are going to be overloaded. >> >> I am quite lazy when in python, so this is too many default parameters to have to specify. >> >> Thanks, >> Brad >> >> >> [1] >> https://github.com/SimpleITK/SimpleITK/blob/master/Code/BasicFilters/ >> include/sitkAdditionalProcedures.h#L45 >> --------------------------------------------------------------------- >> --------- See everything from the browser to the database with >> AppDynamics Get end-to-end visibility with application monitoring >> from AppDynamics Isolate bottlenecks and diagnose root cause in >> seconds. >> Start your free trial of AppDynamics Pro today! >> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg. >> clktrk _______________________________________________ >> Swig-user mailing list >> Swi...@li... >> https://lists.sourceforge.net/lists/listinfo/swig-user > > ---------------------------------------------------------------------- > -------- See everything from the browser to the database with > AppDynamics Get end-to-end visibility with application monitoring from > AppDynamics Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.c > lktrk _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Swig-user mailing list Swi...@li... https://lists.sourceforge.net/lists/listinfo/swig-user |