473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem in adding data to hash of hash

I need to create a hash of hash in python.
>>> x = {}
>>> y = 42
>>> z = 'first'
>>> x = {y:{z:'first value'}}
>>> x
{42: {'first': 'first value'}}

This is working but if I try to add another value, it is not working.. x is having only the current value..

>>> y = 45
>>> z = 'second'
>>> x = {y:{z:'Second value'}}
>>> x
{45: {'second': 'second value'}}

Now x is having only this value.

Can anyone please tell me how to add values..
Thank you..
Apr 7 '11 #1
1 1577
dwblas
626 Expert 512MB
The second values overlays the first value ("z") as you can not have duplicate keys in a dictionary. This is poor style. Consider SQLite instead (getting started) as you can have duplicate entries and can select for a match on multiple fields.
Apr 7 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Probst | last post by:
Hi all, I am new to .NET and the way XML data is handled in .NET I wrote a small application with .NET forms in C++ The application reads data from an XML file to fill-in the fields of the...
1
by: Brian Conklin | last post by:
Hello Eneryone, I am having a problem. I have written a little app that will take a text "pipe" delimited file and place all of the values in to an Excel spreadsheet. It works great on any of my...
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
1
by: Joel Byrd | last post by:
I am having a problem adding a node to the page. This works on other browser (Opera, Firefox, etc.), but not in IE. The following is the function to add the node: (the id "test_div" is a...
2
by: Joe | last post by:
Anyone can suggest the best method of reading XML and adding data to ListView? Here is the xml data structure:: <xml> <site> <url>http://www.yahoo.com</url> <lastupdate></lastupdate>...
14
by: Karl Irvin | last post by:
While adding data to a record set, I use something like rst! = some variable rst! = some variable ...... rst! = some variable The rst! , rst! etc. are manually typed in and it gets...
1
by: kiny3k | last post by:
hi in my data grid after binding the grid n adding new rows, the new rows which are added are been displayed in starting of grid rather then at end, can any one provide me solution for adding data in...
0
by: dlbriggs1729 | last post by:
I am wrinting a data service to access and update a datset. I am having problem when I try to add a SqlConnection to a web service. Using C# in VS 2005 I started a new web service project. Then I ...
3
by: SimonHeffer | last post by:
I've added a DataGridView and added some columns in the designer, now I want to add some rows with data applied via column name. Having done some web trawling I've ended up with this: private...
2
by: canoewhiteh2o | last post by:
I am having trouble adding data columns to a disconnected database. I first load a datatable using: private DataTable dtMacros = new DataTable(); private ArrayList macro = new ArrayList();...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.