[PyQt] dip model types, properties, and syntax
Phil Thompson
phil at riverbankcomputing.com
Mon Oct 11 15:17:17 BST 2010
On Wed, 15 Sep 2010 10:31:48 -0400, Darren Dale <dsdale24 at gmail.com>
wrote:
>> 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.
Agreed - implemented in the current snapshot.
> 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.
I don't understand either...
Phil
More information about the PyQt
mailing list