pre-PEP: Suite-Based Keywords

Shane Hathaway shane at hathawaymix.org
Mon Apr 18 01:08:00 EDT 2005


Brian Sabbey wrote:
> Maybe using '**' would be better than '...' since it already is used to
> indicate keyword arguments.  Example:
> 
> class C(object):
>     x = property(**):
>        doc = "I'm the 'x' property."
>        def fget(self):
>           return self.__x
>        def fset(self, value):
>           self.__x = value
>        def fdel(self):
>           del self.__x

Looks good to me.  You should update the pre-PEP and submit it again to
the list.

This syntax might also be a good replacement for event handling when
lambda goes away (as Guido announced in his PyCon 2005 keynote.)

    button = Button(self, "Push me")
    button.addHandlers(**):
        def onmouseover(event):
            self.textBox.setText("Are you going to push me?")
        def onmouseout(event):
            self.textBox.setText("Too shy.  Goodbye.")
        def onclick(event):
            self.textBox.setText("Ouch!")
        oncontextmenu = self.oncontextmenu

Shane



More information about the Python-list mailing list