You're right...how strange. Here's the whole code: tables = [] bst = [] bdt = [] spt = [] sst = [] sstp = [] cursor.execute('show tables;') all = cursor.fetchall() for a in all: tables.append(a[0]) for table in tables: if table[0] == 'b': # This is a basic table if table[1] == '0': # This is a basic static table bst.append(table) # elif table[1] == '1': # This is a basic dynamic table # bdt.append(table) # Basic dynamic tables, like "pic" below, have to be manually created. elif table[0] == 's': # This is a store table if table[1] == '0': # This is a store primary table spt.append(table) elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) print sst print '<br />' print sstp print '<br />' print subtypes print '<br />'
This is what prints out: ['doctors', 'patient'] ['prescriptions', 'prescriptions'] {'prescriptions': 'patient'} TIA, V On Fri, Oct 9, 2009 at 12:10 PM, Stephen Hansen <apt.shan...@gmail.com>wrote: > > > On Fri, Oct 9, 2009 at 10:02 AM, Victor Subervi > <victorsube...@gmail.com>wrote: > >> Hi; >> I have the following code: >> >> elif table[0] == 't': # This is a store subtype table >> bits = string.split(table, '0') >> sst.append(bits[2]) >> sstp.append(bits[1]) >> subtypes = dict(zip(sstp, sst)) >> >> When I print these out to screen, I get this: >> >> sst: ['doctors', 'patient'] >> sstp: ['prescriptions', 'prescriptions'] >> subtypes: {'prescriptions': 'patient'} >> >> Why do I only get one item from sst and sstp zipped? Why not both?? > > I think you have a logic problem that's not shown in that code sample: > > >>> sst = ['doctors', 'patient'] > >>> sstp = ['prescriptions', 'prescriptions'] > >>> zip(sst,sstp) > [('doctors', 'prescriptions'), ('patient', 'prescriptions')] > >>> dict(zip(sst,sstp)) > {'patient': 'prescriptions', 'doctors': 'prescriptions'} > >>> > > --S >
-- http://mail.python.org/mailman/listinfo/python-list