|
From: Robert W. B. <rb...@di...> - 2001-08-19 01:44:04
|
Hello,
On Sat, 18 Aug 2001, m klenin wrote:
> Sorry to be a pain, but did manage to log onto SourceForge, and hoped to
> submit this to your faq using my SF id and pwd. It got refused. Pls
> help!!
>
> Subject:Indefinite number of functional arguments
>
>
> Question:
>
>
> The statement (e.g.)
>
> def functionName ( arg1, *otherArgs)
>
> is really useful sometimes and has no real equivalent in java.
> Tried (with no success) all the ways I can think of to convert this to
> (e.g.)
>
> public String functionName( java.lang.String arg1,
> java.lang.String [] otherArgs )
>
> Does anyone have any suggestions?
The basics of this issue lies in the FAQ entry 5.3. Supporting keyword
arguments in Java Methods. The short story is use a sig like the
following:
public PyObject myMethod(PyObject[] args, String[] kw)
Then parse those arguments with org.python.core.ArgParser
ArgParser ap = new ArgParser("myMethod", args, kw, "Var1");
I changed the title of that FAQ entry, and added a note about referencing
the Javadocs for org.python.core.ArgParser. I hope this is OK with others.
New title= "5.3. Supporting *args and **kw in Java methods"
This might not be ideal either, but it will catch more curious eyes
because of the "*args, **kw" familiarity to Python folk.
Cheers,
Robert
|