[PyQt] dip model types, properties, and syntax

Darren Dale dsdale24 at gmail.com
Wed Sep 15 15:31:48 BST 2010


> class ExampleModel(Model):
>
>     name = Str()
>
>     @name.getter
>     def name(self):
>         return self._name

I have an additional suggestion to follow up on this syntax. If a
model type's __call__ method were changed to call its getter method,
rather than return the default value, I think it would be possible to
do:

class Test(Model):

    foo = Str()

    @Str()
    def bar(self):
        return self._bar


That seems like a natural extension of the syntax to me, very similar
to using python's property built-in as a decorator. As things
currently stand, I thought we should already be able to do:

class Test(Model):

    foo = Str()

    @Str().getter
    def bar(self):
        return self._bar


but for reasons I don't understand, that raises a SyntaxError.

Darren


More information about the PyQt mailing list