[Tutor] list of dictionary
Pacific Morrowind
pacificmorrowind at gmail.com
Sat Feb 26 02:38:51 CET 2011
On 25/02/2011 9:44 AM, Patty wrote:
>
> ----- Original Message -----
> *From:* Pacific Morrowind <mailto:pacificmorrowind at gmail.com>
> *To:* tutor at python.org <mailto:tutor at python.org>
> *Sent:* Thursday, February 24, 2011 10:21 PM
> *Subject:* Re: [Tutor] list of dictionary
> <snip>
> Presuming you do have to use the dictionaries:
> qty = 0.0
> for item in d:
>
> Right here - is the variable 'item' created right on the spot to
> iterate over this list? And I think you are doing the same thing
> when you create the variable 'subitem' in the line below, right?
> I am trying to get myself to recognize an iterator variable as
> opposed to a counter variable I create myself to keep track of
> these things (used in other programming languages) - and realizing
> the difference between counter/iterator variables and variables
> that I really care about like
> 'd = []' .
> Thanks!
> Patty
>
yes and yes. both item and subitem are created on the spot; anychunk of
python code like:
for x in y:
will create x as a variable and with each iteration x refers to the next
item in y;
Of course if I knew the function of the list/dictionary I'd name them
something more informative than item and subitem - like f.e. for lap in
d and for time in d if it was refering to races.
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110225/5cdd0d59/attachment.html>
More information about the Tutor
mailing list