On Wed, Jul 16, 2008 at 11:01 AM, Marty Alchin <[EMAIL PROTECTED]> wrote:
> Of course, you're welcome to go with Scott's suggestion of doing all
> the math in one line, but it loses a bit readability going that way.
> On the flip side, it probably executes slightly faster, but probably
> not enoug
People here are right: remove the "not". You want to keep adding blanks
until the total length is zero mod 4. Then, at line 19 in the dpaste,
change the loop to: for blank in range(amountofblanks). You shouldn't
be subtracting one from the value there.
--Ned.
http://nedbatchelder.com
Marty
On Wed, Jul 16, 2008 at 11:46 AM, Joshua Jonah <[EMAIL PROTECTED]> wrote:
> 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.
I apolo
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 modul
Joshua Jonah wrote:
I'm not sure how to put the "better fix", would it be in the while
statement? should it be child of the statement?
I tried the "simple fix" and it isn't working either. It returned a list
of 33 items in one of the sections, that would work out to 8.25.
Obviously it is div
I'm not sure how to put the "better fix", would it be in the while
statement? should it be child of the statement?
I tried the "simple fix" and it isn't working either. It returned a list
of 33 items in one of the sections, that would work out to 8.25.
Obviously it is divisible, but i dont wan
Joshua,
For the simple fix, I think you should remove the word "not" from your while
condition.
The better fix is to do the math all in one step:
amountofblanks += (4 - (len(templist) + amountofblanks) % 4) % 4
-- Scott
On Wed, Jul 16, 2008 at 10:30 AM, joshuajonah <[EMAIL PROTECTED]> wrote:
I have a form model that is generating a dynamic number of fields. It
is using a modulo conditional to see if the amount of fields if
divisible by 4 (4 column layout). If it doesn't divide, it adds
another field and then tries again.
This is not working, it is returning field lists that are 30 (/
8 matches
Mail list logo