hash of hashes

S

sfo

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


thanks.

--RR
 
M

Marc 'BlackJack' Rintsch

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
 
T

Tim Chase

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:
{42: {'foonting turlingdromes': 'crinkly bindlewurdles'}}


-tkc
 
S

sfo

Thanks to all for the feedback. it worked.

--RR

Tim said:
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:
{42: {'foonting turlingdromes': 'crinkly bindlewurdles'}}


-tkc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top