[Zope-Perl] Python void context

Ken Manheimer klm@digicool.com
Fri, 26 May 2000 18:30:22 -0400 (EDT)


Gisle Aas gisle@ActiveState.com writes:
> Chris McDonough <chrism@digicool.com> writes:
> 
> > It occurs to me that you could define a context default keyword argument
> > to the Perl function e.g.
> > 
> > obj.func(1,2,context="list")
> > obj.func(1,2,context="scalar")
> > obj.func(1,2,context="void")
> > 
> > Where func's signature defines context as a default:
> > 
> > func(self, arg1, arg2, context="list")
> > 
> > This seems to be the 'pythonic' way of dealing with such a thing.  I'm
> > not sure how you're implementing a Perl function wrapper, so I'm not
> > sure if this suits you.
> 
> Currently I just ignore keyword arguments so this is doable.  It might
> be in conflict with other mappings of keyword arguments that we want
> to do insted, but reserving some namesspace like __*, i.e. use
> __context="list" etc. should be ok.

I think this is a good idea!  In particular, to use something with a
leading *and* trailing '__':

  obj.method(args, __context__="scalar")

(maybe also spelled obj.method(args, __context__="$")

The deal is that it's common in python for special things (methods,
vars) to be bracketed with '__'.  Because of the special status, i
don't think you need to worry about the concern chris raises about the
name pseudo-private name mangling of method vars that begins with '__'
(see http://lists.zope.org/pipermail/zope-perl/2000-May/000012.html )
- names that have a leading *and* trailing '__' are exempt (because
it's the conventional form for special python variables).

Ken Manheimer
klm@digicool.com