Yeah, but the point is to make the list exactly divisible, is there a 
better way to do this? I'm then taking the number of fields and dividing 
them by four, then outputting that number of items in each column.


> The 'simple fix', to remove 'not' from the statement works because of 
> how modulo works, which works like this:
>
>    >>> 10 % 4
>    2
>
> The modulo returns the /remainder/. It will not be a float.
>
> Let's see how this evaluates::
>
>    >>> if 10 % 4:
>    ...    print "true"
>    ...
>    true
>
> If the modulo returns anything other than 0, it will evaluate to True. 
> In python any integer other than 0 evaluates to True. You are treating 
> modulo like it is an operation to find out if the second number goes 
> into the first number an even amount of times. That's why removing the 
> 'not' is the 'simple fix'.
>
> So if there isn't enough fields for 4 columns, say 11, 11 % 4 will 
> evaluate to true. Add one more, and 12 % 4 will evaluate to false.
>
> The 'good fix' is set up to do the logic all at once. Because modulo 
> returns an integer, you can just set the number of blank fields to the 
> number that modulo returns.
>
> Hopefully that helps!
>
>
> Jeff Anderson
>


--~--~---------~--~----~------------~-------~--~----~
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