In PHP I can name my array indices so that I may have something like:
JavaScript
x
3
1
$shows = Array(0 => Array('id' => 1, 'name' => 'Sesame Street'),
2
1 => Array('id' => 2, 'name' => 'Dora The Explorer'));
3
Is this possible in Python?
Advertisement
Answer
This sounds like the PHP array using named indices is very similar to a python dict:
JavaScript
1
5
1
shows = [
2
{"id": 1, "name": "Sesaeme Street"},
3
{"id": 2, "name": "Dora The Explorer"},
4
]
5
See http://docs.python.org/tutorial/datastructures.html#dictionaries for more on this.