Re: accessing keys in dict

2007-08-25 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], james_027 wrote: is there any difference between .. for key in a_dict: from for key in a_dict.keys(): I'm assuming the former is equivalent to for key in a_dict.iterkeys() : -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing keys in dict

2007-08-25 Thread Dustan
On Aug 25, 7:41 am, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED], james_027 wrote: is there any difference between .. for key in a_dict: from for key in a_dict.keys(): I'm assuming the former is equivalent to for key in

Re: accessing keys in dict

2007-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2007 19:05:07 +, Dustan wrote: Never assume. A better approach would be to experiment: I assume that you would not like it if I poked you in the eye with a sharp stick, but perhaps I better experiment... *wink* More seriously, if you wish to compare dict.keys() and

accessing keys in dict

2007-08-14 Thread james_027
hi, a_dict = {'name':'apple', 'color':'red', 'texture':'smooth', 'shape':'sphere'} is there any difference between .. for key in a_dict: from for key in a_dict.keys(): which is more preferred? any difference in performance? THanks james --

Re: accessing keys in dict

2007-08-14 Thread James Stroud
james_027 wrote: hi, a_dict = {'name':'apple', 'color':'red', 'texture':'smooth', 'shape':'sphere'} is there any difference between .. for key in a_dict: from for key in a_dict.keys(): which is more preferred? Use the first. any difference in performance? It doesn't