For the first time this is not python => php but php => python.
I’ve got small problem with arrays in python.
(I’ve already been to docs.python.org)
Here’s my problem:
I get in python couples of strings like this:
(People 1):
<criteria a> <data of the criteria>
<criteria b> <data of the criteria>
<criteria c> <data of the criteria>
<criteria d> <data of the criteria>
(People 2):
<criteria a> <data of the criteria>
<criteria b> <data of the criteria>
<criteria d> <data of the criteria>
...
(note for people 2 criteria c doesn’t exist)
So i’d like do that (in php it’s very easy):
array_push( tab[ "criteria a" ],
array("People1", "data of the criteria")
);
Then I’d like to show all a list of the criterias that exists, and use the array to create a nice “insert SQL query” for my database.
Any idea how to do this?
Where should I look?
I miss string indexed arrays….
In Python you have “dictionaries” instead of “string indexed arrays”.
Their syntax is different than for arrays.
You can do
…
You can retrieve all contents of a dictionaries values using the values method:
(note that order is arbitrary when you do this)
Anyway, you’d better check the documentation on Python basic data structures to do this:
http://docs.python.org/tutorial/datastructures.html