[PyQt] dip @setter bug?

Robert Kent rob at gulon.co.uk
Fri Jun 15 19:21:42 BST 2012


Hi,

I'm just starting to play with dip as I think the idea is very cool. I have however either missed something (likely) or found a bug (unlikely). Running the following code:

############################
############################
from dip.model import Model, Int, Str

class ExampleModel(Model):
    name=Str()
    address=Str()
    age=Int(30)

    @name.default
    def name(self): return 'Default'

    @name.setter
    def name(self, name):
        self._name=name.upper()
        print "Set:", self._name

    @name.getter
    def name(self):
        return self._name

model=ExampleModel()
print "Name:", model.name
print "Address:", model.address
print "Age:", model.age

model.name="bill"
print "Name:", model.name

############################
############################

I get the following output:

Name: Default
Address: 
Age: 30
Set: BILL
Name: bill

I would expect the 'Name: bill' line to read 'Name: BILL' as proved by the print in the decorator… why doesn't it? Is the default setter being called subsequently to my decorated function for some reason?

Thanks very much in advance,

Rob



More information about the PyQt mailing list