Second attempt WAS: From Dict to Classes yes or no and how

James Mills prologic at shortcircuit.net.au
Tue Jun 22 08:27:00 EDT 2010


On Tue, Jun 22, 2010 at 10:03 PM, Jerry Rocteur <macosx at rocteur.cc> wrote:
> How do I iterate through and access an individual user record!

A much better question! :)

You are in fact already demonstrating that you know full
well how to access a specific user record - by accessing
a parent dictionary holding a mapping of user -> user record.

You select a user record by key.

>>> users["Bob Jane"]

Your example of a user record if perfectly fine to me.

If you wanted to iterate over all user records:

>>> for k, v in users.items():
...   # some code here

cheers
James

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list