> def compare(self, item, column, ascending):
> try:
> a = int(str(self.text(column)))
> except (ValueError, ):
> a = self.text(column)
> try:
> b = int(str(item.text(column)))
> except:
> b = item.text(column)
> return cmp(a, b)
>
Actually, this should be a smidge better:
def compare(self, item, column, ascending):
a = self.text(column)
b = item.text(column)
try:
a = int(str(a))
except (ValueError, ):
pass
try:
b = int(str(b))
except:
pass
return cmp(a, b)
With this one, you'll only pay for the call to text() once, even if the value
can't be converted to an int.
--
Troy Melhase, [EMAIL PROTECTED]
--
I have sworn upon the altar of God eternal hostility against every form of
tyranny over the mind of man. - Thomas Jefferson
_______________________________________________
PyKDE mailing list [EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde