Nathan,
Thanks for your help...I got it working. This is what I used:
if values != list("0"):
Is that what you were recommending? Because I couldn't convert a list
(values) to a int. Since values was a list I decided to convert my
int to a list and that worked. Can you tell me what the u stands for
when i do a 'assert False, values': It returns a [u'0']. Why doesn't
it just return a ['0']? Also, it there anyway that I can convert the
'values' variable to a int so that I can do a comparison without
converting the 0 to a list?
Thanks
On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---