Skip to content

Python dict for arrays

wordpress meta

title: 'Python Dict for Arrays'
date: '2017-01-22T12:30:31-06:00'
status: publish
permalink: /python-dict-for-arrays
author: admin
excerpt: ''
type: post
id: 1033
category:
    - Python
tag: []
post_format: []

Some more examples of Python dicts and array general use.

import pprint

###  Example python dict as an associative multi array
###  Example is using an unique key
pp = pprint.PrettyPrinter(indent=2)

table = {}
table[1]={'LastName':'Sable','name':'Sam'}
table[2]={'LastName':'Sable','name':'Samantha'}
table[3]={'LastName':'Sable','name':'Stevie'}

pp.pprint(table)

print table[2]
print table[3]['name']