[Tutor] assigning values to dictionary

jeremiah jeremiah.jester at panasonic.aero
Fri Oct 3 20:02:34 CEST 2008

i think i figured it out. The result is that I have a dictionary within
a dictionary..i think.

for example:

{'mcdonalds': {'hamburger': 'big mac','drink':'coke'}}

How would I go about itterating through this?


On Fri, 2008-10-03 at 10:39 -0700, Steve Willoughby wrote:
> On Fri, Oct 03, 2008 at 10:29:13AM -0700, jeremiah wrote:
> > I have a list of dictionary values that i am looping through that
> upon
> > each iteration I would like to assign these values to a new
> dictionary
> > name.
> >
> > For example...
> >
> > item=0
> > for line in some_dict:
> >       ## some how assign dict values to new name
> >       "new_dict_name_"+item = line
> You could use eval, I suppose, but are you sure that
> making up new dictionary names on the fly like that is
> the solution that best fits the problem as opposed to
> having, say, a set of objects or an overall dictionary
> of dictionaries you add to?  What's the bigger context
> this fits into?  Although you *can* do this sort of thing,
> it quite often ends up not being the most elegant thing
> to do.
> --
> Steve Willoughby    |  Using billion-dollar satellites
> steve at alchemy.com   |  to hunt for Tupperware.

Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.

More information about the Tutor mailing list