[Zope-Perl] Calling python functions with keyword arguments from perl

Gisle Aas gisle@ActiveState.com
15 Aug 2000 21:06:24 +0200


David Ascher <DavidA@ActiveState.com> writes:

> On 15 Aug 2000, Gisle Aas wrote:
> 
> > Other potential interfaces I could think of include:
> > 
> >   * Use some specific object to wrap the keyword arguments.  It looks
> >     uglier than the plain hash, will be slower, but will be safe from
> >     surprises.
> > 
> >        $obj->foo($pos1, $pos2, KW( key1 => $val1, key2 => $val2 ));
> 
> That one is my personal favorite for now, as it is the safest while not
> being _too_ ugly.

You would also have to import the KW constructor function before you
can use it.

  use Python qw(KW);

which tilts it in the direction of _too_ ugly in my taste.


Another silly(?) idea. We could misuse globs, as I can't see a reason
why you would want to pass them to a python function otherwise:

   $obj->foo($pos1, $pos2, *key1 => $val1, *key2 => $val2);

This is kind of similar to :keyword symbols used in Lisp.  One
downside is that these symbols seems to stick forever in the symbol
table after use.

Regards,
Gisle