On Wed, 29 Aug 2007, Scott Oertel wrote: > John Fouhy wrote: > > On 29/08/07, Trey Keown <[EMAIL PROTECTED]> wrote: > > > >> attrs={u'title': u'example window title', u'name': u'SELF', u'icon': > >> u'e.ico'} > >> keys = ['name','title','icon'] > >> for (tag, val) in attrs.iteritems(): > >> for key in keys: > >> print val > >> > >> the first "for" tag causes the dictionary (attrs) to have its keys called > >> "tag" and its value called "val". The second "for" loop causes the > >> dictionary keys to be read in a certain order. How could I take away the > >> first "for" loop and replace it with something else to do the same general > >> function? > >> > > > > for key in keys: > > print 'Attribute %s has value %s' % (key, attrs[key]) > > > > > Why even have the keys variable at all.. > > for key in attrs: > print 'Attribute %s has value %s' % (key, attrs[key])
In a prior email thread, the OP indicated that he needed to process the keys in that particular order; and it's not really amenable to any sort. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor