Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Python only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
Python
hash of hashes
hash of hashes
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
sfo
#1
hash of hashes
Jul 11 '06, 07:35 PM
how do i create a hash of hash similar to perl using dict in python
$x{$y}{z}=$z
thanks.
--RR
Ant
#2
Jul 11 '06, 07:55 PM
Re: hash of hashes
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!
Comment
Post
Cancel
Marc 'BlackJack' Rintsch
#3
Jul 11 '06, 07:55 PM
Re: hash of hashes
In <1152646733.156 556.190950@75g2 000cwc.googlegr oups.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
Comment
Post
Cancel
Tim Chase
#4
Jul 11 '06, 07:55 PM
Re: hash of hashes
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
Comment
Post
Cancel
sfo
#5
Jul 11 '06, 09:15 PM
Re: hash of hashes
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
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment