To illustrate with the Python shell:

>>> 0 == "0"
False
>>> 0 == int("0")
True

On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote:
> On Jul 27, 2007, at 10:36 PM, Greg wrote:
>
> > AssertionError at /rugs/cart/addpad/
> > [u'0']
>
> > Does that mean that the value is 0?  below is my view function and
> > template code:
>
> That little 'u' in front of the '0' means unicode so the value is the
> unicode string "0" not the number zero. Very different as far as
> Python is concerned. You may be used to other scripting languages
> that auto-convert. Python is not one of them.
>
> try:
>      num = int(values)
>      if num == 0:
>          deal_with_zero()
>      else:
>          deal_with_number(num)
> except ValueError:
>     # hmm, values is a string, not a number
>     deal_with_a_string(values)
>
> Hope that helps.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to