Won't work with non-integer values. Sometimes I have string keys.

On Aug 4, 4:25 pm, Branko Vukelić <[email protected]> wrote:
> On 2011-08-04 05:14 -0700, andrei wrote:
>
> > I've subclassed form.Dropdown, and  modified comparison to
> > str(self.value) == str(value)
>
> Wasn't it better to do do somethinglike:
>
>     self.value == cleanint(value)
>
> where cleanint() would try to convert string to integer and return None
> on failure?
>
>     def cleanint(v):
>         try:
>            return int(v)
>         except TypeError: # or was it ValueError?
>            return None
>
> --
> Branko Vukelic
> [email protected]
> [email protected]
>
> Lead Developer
> Herd Hound (tm) - Travel that doesn't bitewww.herdhound.com
>
> Love coffee? You might love Loveffee, too.
> loveffee.appspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to