Mailing List Archive

Aside: apply syntax
I've seen repeatedly on c.l.p a suggestion to modify the syntax & the core
to allow * and ** in function calls, so that:


class SubFoo(Foo):
def __init__(self, *args, **kw):
apply(Foo, (self, ) + args, kw)
...

could be written

class SubFoo(Foo):
def __init__(self, *args, **kw):
Foo(self, *args, **kw)
...

I really like this notion, but before I poke around trying to see if it's
doable, I'd like to get feedback on whether y'all think it's a good idea
or not. And if someone else wants to do it, feel free -- I am of course
swamped, and I won't get to it until after rich comparisons.

FWIW, apply() is one of my least favorite builtins, aesthetically
speaking.

--david
Re: Aside: apply syntax [ In reply to ]
On Thu, 10 Jun 1999, David Ascher wrote:


> class SubFoo(Foo):
> def __init__(self, *args, **kw):
> apply(Foo, (self, ) + args, kw)
> ...
>
> could be written
>
> class SubFoo(Foo):
> def __init__(self, *args, **kw):
> Foo(self, *args, **kw)

Of course I meant Foo.__init__ in both of the above!

--david
Re: Aside: apply syntax [ In reply to ]
> I've seen repeatedly on c.l.p a suggestion to modify the syntax & the core
> to allow * and ** in function calls, so that:
>
> class SubFoo(Foo):
> def __init__(self, *args, **kw):
> apply(Foo, (self, ) + args, kw)
> ...
>
> could be written
>
> class SubFoo(Foo):
> def __init__(self, *args, **kw):
> Foo(self, *args, **kw)
> ...
>
> I really like this notion, but before I poke around trying to see if it's
> doable, I'd like to get feedback on whether y'all think it's a good idea
> or not. And if someone else wants to do it, feel free -- I am of course
> swamped, and I won't get to it until after rich comparisons.
>
> FWIW, apply() is one of my least favorite builtins, aesthetically
> speaking.

I like the idea, but it would mean a major reworking of the grammar
and the parser. Can I persuade you to keep this on ice until 2.0?

--Guido van Rossum (home page: http://www.python.org/~guido/)
Re: Aside: apply syntax [ In reply to ]
> >
> > class SubFoo(Foo):
> > def __init__(self, *args, **kw):
> > Foo(self, *args, **kw)
> > ...

Guido:
> I like the idea, but it would mean a major reworking of the grammar
> and the parser. Can I persuade you to keep this on ice until 2.0?

What exactly would the semantics be? While I hate the apply() loops you have
to jump through nowadays to get this behaviour I don't funny understand how
this would work in general (as opposed to in this case). For instance, would
Foo(self, 12, *args, **kw)
be allowed? And
Foo(self, *args, x=12, **kw)
?
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
Re: Aside: apply syntax [ In reply to ]
On Fri, 11 Jun 1999, Guido van Rossum wrote:

> > I've seen repeatedly on c.l.p a suggestion to modify the syntax & the core
> > to allow * and ** in function calls, so that:
> >
> I like the idea, but it would mean a major reworking of the grammar
> and the parser. Can I persuade you to keep this on ice until 2.0?

Sure. That was hard. =)
Re: Aside: apply syntax [ In reply to ]
On Fri, 11 Jun 1999, Jack Jansen wrote:

> What exactly would the semantics be? While I hate the apply() loops you have
> to jump through nowadays to get this behaviour I don't funny understand how
> this would work in general (as opposed to in this case). For instance, would
> Foo(self, 12, *args, **kw)
> be allowed? And
> Foo(self, *args, x=12, **kw)

Following the rule used for argument processing now, if it's unambiguous,
it should be allowed, and not otherwise. So, IMHO, the above two should
be allowed, and I suspect

Foo.__init__(self, *args, *args2)

could be too, but

Foo.__init__(self, **kw, **kw2)

should not, as dictionary addition is not allowed.

However, I could live with the more restricted version as well.

--david