total idiot question: +=, .=, etc...

Greg Ewing greg.ewing at compaq.com
Mon Jun 28 00:48:28 CEST 1999


Michael Hudson wrote:
> 
> class Derived(base.Base):
>     def __init__(self,x,y,z,**kw):
>         apply(base.Base.__init__,(self,x,y),kw)
>         print z
> 
> which I think is one of the ugliest things I've ever seen in Python
> that I couldn't think of a prettier way round. Ideas, anyone?

Yes! With the calling syntax extension that I
have proposed before, that would be written

   Base.__init__(self, x, y, **kw)

Still requires the self argument, but I think
you'll agree it's a lot better than having to
use apply!

I'd also like a way of getting rid of the self
argument in that situation as well, but this seems
to be quite a difficult problem to solve within
Python's existing execution model. I haven't
thought of a good solution yet.

Greg




More information about the Python-list mailing list