Newbie query - reading text file (with column headings) into dictionary

Mike Meyer mwm at mired.org
Mon Dec 9 00:15:53 EST 2002


"Terry Reedy" <tjreedy at udel.edu> writes:
> "Mike Meyer" <mwm at mired.org> wrote in message
> > Personally, I don't think this belongs in a cookbook, because it
> > slices the data in an unusual direction. If you sliced it the other
> > way - making each line an object, instead of each column - then
> > accessing individual data elements is nearly identical: you just
> swap
> > the order of the subscripts. However, you're more likely to want to
> > deal with a line as an individual object than a column.
> Fortran (at least in the past) slices arrays in this 'unusal
> direction'.

I'm well aware of that. In fact, my first reaction to this was "Why is
he using the FORTRAN hack for emulating structures."

This isn't FORTRAN, it's Python. You don't need to emulate structures,
you have classes.

> It facilitates adding new columns (new = log(old),

Adding new featuers to a class is easy: my.new = log(my.old).

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list