Interpolation (was: Keyword calling gotcha ?)

Marko Schulz 4mschulz at informatik.uni-hamburg.de
Thu May 27 12:11:18 EDT 1999


Darrell <news at dorb.com> wrote:
> Evan Simpson <evan at tokenexchange.com> wrote in message
> news:AXX23.14$KR2.13445 at news.corridex.com...
>>
>> Replace "A.__init__(self, parms)" with "apply(A.__init__, (self,),
>> parms)".  "A.__init__" is expecting one fixed parameter plus any
>> number of keyword parameters.  You're calling it with two fixed
>> parameters, one of which happens to be a dict obtained from keyword
>> parameters.
>
> Yes I see the problem.
> But I don't like it.
> Keyword parms aren't as useful as I though they might be.
> Using apply all over the place is not appealing.

It would be nice to have a way of interpolating sequences in parameter
lists. In Perl it is done automatically, which causes confusion
regularly, but it would be nice in Python sometimes too.

If it were done with a new function one could also write a function,
that computes all base_classes to a class on-the-fly:
    class Derived( interpolate(base_classes(args)) ):
       :
       :  

At the moment base_classes may only return one base class. Many
apply(function,args) could be turned into function( interpolate(args) )

This would be especially nice for those (self,)-Tupels, as it was used
in the original posting above.

Of cause a nicer syntax oder name than interpolate() might be found.

-- 
marko schulz
              "Die Welt ist gut, die Welt ist schlecht.
               Ich seh' mehr als ich begreifen kann. Ich sehe in 3-D."
                                                         '3-D', Extrabreit




More information about the Python-list mailing list