473,473 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

hash of hashes

sfo
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z
thanks.

--RR

Jul 11 '06 #1
4 15077
Ant

sfo wrote:
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z
Haven't done any Perl in a long while (thankfully ;-) ) so I'm not
quite sure on your syntax there, but here's how to do it in Python:
>>x = {'y': {'z': 'My value'}}
x['y']['z']
'My value'

Much easier to understand than that crazy perl syntax!

Jul 11 '06 #2
In <11**********************@75g2000cwc.googlegroups. com>, sfo wrote:
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z
Just put dictionaries as values into a dictionary.

Ciao,
Marc 'BlackJack' Rintsch
Jul 11 '06 #3
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z
Pretty much the same as in perl, only minus half the crazy abuses
of the ASCII character-set.

Okay...well, not quite half the abuses in this case...
>>x = {}
y = 42
z = 'foonting turlingdromes'
x[y] = {}
x[y][z] = 'crinkly bindlewurdles'
Or, if you want to do it in a single pass:
>>x = {y:{z:'crinkly bindlewurdles'}}
x
{42: {'foonting turlingdromes': 'crinkly bindlewurdles'}}
-tkc


Jul 11 '06 #4
sfo
Thanks to all for the feedback. it worked.

--RR

Tim Chase wrote:
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z

Pretty much the same as in perl, only minus half the crazy abuses
of the ASCII character-set.

Okay...well, not quite half the abuses in this case...
>>x = {}
>>y = 42
>>z = 'foonting turlingdromes'
>>x[y] = {}
>>x[y][z] = 'crinkly bindlewurdles'

Or, if you want to do it in a single pass:
>>x = {y:{z:'crinkly bindlewurdles'}}
>>x
{42: {'foonting turlingdromes': 'crinkly bindlewurdles'}}
-tkc
Jul 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: andreas gammel | last post by:
I want to use Perl hash functionality (hashes of hashes, arrays of hashes, hashes of arrays) in my C programs. Other Perl functions (split, chomp, regular expressions) would be welcome too. ...
1
by: bb | last post by:
I have a requirement to create and store in our database the users password in a couple of additional hashes (we currently store an MD5 hash) the spec is pretty brief... Spec: Store the NT...
14
by: John Coleman | last post by:
Greetings, I am currently trying to learn Python through the excellent "Learning Python" book. I wrote my first non-trivial program, which began with several comment lines. One of the comment...
10
by: Qiangning Hong | last post by:
I'm writing a spider. I have millions of urls in a table (mysql) to check if a url has already been fetched. To check fast, I am considering to add a "hash" column in the table, make it a unique...
24
by: kdotsky | last post by:
Hello, I am using some very large dictionaries with keys that are long strings (urls). For a large dictionary these keys start to take up a significant amount of memory. I do not need access to...
11
by: merrittr | last post by:
Hi in the code below in the main the hash table from K&R example replaces a node when a collision occurs What I am trying to do is set it up to "chain" another structure beside the node that it...
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
4
by: ChipAuger | last post by:
Hello Group, Thank you in advance to the group for all responses and help. I'm looking for a 1-way hash for storing passwords on an older embedded system that would be computationally stressed...
4
by: MS | last post by:
Hi, I'm writing a PHP login script for a web site. I've looked at several examples on the web and some of them use MD5 hashes for the password. They do this in various ways. EG. a) Storing...
1
by: sixtyfootersdude | last post by:
Good Morning! I am a perl newbie and I think that I am struggling with references. I have an array of references to hashes which I am trying to print. This is what I have: for(my...
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...
1
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.