473,396 Members | 2,009 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,396 software developers and data experts.

how to build hash tables?

Hi,
first, i'm new with python.. so,i need a help..
ok,i have a dictionary with many keys. this is a simple example.

dict = { was : [ (2,1) ],
a : [ (3,4) , (4,7) ],
and : [ (1,7) ] }

I want to hashing the dict value to the hash table. for example,

hash "was" == was --> 2,1
hash "a" == a --> 3,4 -->4,7

How I do this with Python? Ideas?
Thanks.
Dec 10 '07 #1
1 2590
bvdet
2,851 Expert Mod 2GB
Hi,
first, i'm new with python.. so,i need a help..
ok,i have a dictionary with many keys. this is a simple example.

dict = { was : [ (2,1) ],
a : [ (3,4) , (4,7) ],
and : [ (1,7) ] }

I want to hashing the dict value to the hash table. for example,

hash "was" == was --> 2,1
hash "a" == a --> 3,4 -->4,7

How I do this with Python? Ideas?
Thanks.
Do not use a built-in function for a variable name (dict() is a built-in function). Dictionary keys must be immutable. Examples of immutable objects are strings and tuples.
Expand|Select|Wrap|Line Numbers
  1. >>> dd = {'was' : [(2,1)], 'a' : [(3,4), (4,7)], 'and' : [(1,7) ]}
  2. >>> z = 'was'
  3. >>> dd[z]
  4. [(2, 1)]
  5. >>> dd['a']
  6. [(3, 4), (4, 7)]
  7. >>> dd['and'][0] = (0,7)
  8. >>> dd['and'][0]
  9. (0, 7)
  10. >>> 
You lost me when you said "I want to hashing the dict value to the hash table." Could you explain your problem better?
Dec 10 '07 #2

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

Similar topics

4
by: Pelo GANDO | last post by:
Hi everybody ! I am a beginner in C++. I am looking for a (simple if it's possible) source code in C++ about hash table... Thank you ! Pelo
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
1
by: jacob navia | last post by:
Everybody knows that hash tables are fast. What is less known is that perfect hash tables are even faster. A perfect hash table has a hash function and a table layout that avoids collisions...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.