Killing Another Bug
Victor Subervi
victorsubervi at gmail.com
Fri Dec 4 10:52:43 EST 2009
Hi;
I have this code:
for table in tables:
if table == 'products':
optionsCode = optionsCodeProducts
fromForm = prodsFromForm
try:
fn = getattr(options, table)
fromForm = form.getfirst('%s-options' % table)
fromForm = string.split(fromForm[2:-2], "', '")
optionsCode = fn(table, 'specificCode', fromForm)
except:
if table != 'products': # We recall we must add the products table
fields to all tables.
optionsCode = optionsCodeProducts
i = 0
j = 0
oldJ = 0
try:
y = 0
while y < len(optionsCode):
if table == 'prescriptions':
print len(optionsCode) # prints '2'
for inputName in optionsCode[y]:
if table == 'prescriptions':
print len(optionsCode[y]) # prints '7'
print inputName # prints 'Extra-small', which is only the first
inputName in optionsCode[0]
if j != oldJ:
i = 0
oldJ = j
x = '%s-%s%d' % (table, fromForm[y], i)
x = form.getfirst(x)
if x is not None:
ourInputNames.append('%s-%s' % (table, inputName))
i += 1
j += 1
y += 1
except:
pass
As you can see in the supplied comments, when I loop through for table
'prescriptions', it only prints out the first element of each variable. When
I loop through for table 'products', it prints out all of them! Why?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091204/6a07898e/attachment-0001.html>
More information about the Python-list
mailing list