Simple question about python logic.

Carl Banks pavlovevidence at gmail.com
Fri Oct 12 11:58:35 EDT 2007


On Oct 12, 11:32 am, "seungchan... at gmail.com" <seungchan... at gmail.com>
wrote:
> I have a file containing following data. But the dimension can be
> different.
>
> A B C D E F G
> 3 4 1 5 6 2 4
> 7 2 4 1 6 9 3
> 3 4 1 5 6 2 4
> 7 2 4 1 6 9 3
> .
> .
> .
> .
>
> What is the best approach to make a column vector with the name such
> as A B, etc?

Use a dict.  dict objects are the main way we map names to objects on
the fly.  Simple example:

columns = {}
columns["A"] = [3,7,3,3]
columns["B"] = [4,2,4,2]


Filling in the columns with data from your file is left as an
exercise.


Carl Banks




More information about the Python-list mailing list