[Tutor] Fwd: arrangement of datafile

Keith Winston keithwins at gmail.com
Sun Jan 5 21:01:43 CET 2014


Hi Amrita, I'm just a beginner but I notice that, after the first two
entries on each line (i.e. 10,ALA), the rest might fit nicely into a dict,
like this {H: 8.388, HB1: 1.389, ...}. That would give you a lot of
flexibility in getting at the values later. It would be easy enough to
replace the "=" with ':", and add some curly braces. In fact, if you
enclosed each line in square braces, changed =/: and added the curly braces
on the dict, then each line would already be a list containing a
dictionary, and you'd be ready to do some rearranging very easily.

Whether you do that in Python or when you are building your file in
whatever system it's coming from is your call. If you left off the outer
braces, each line is a tuple containing a dict, which works too.

Sorry if all I've done is state the obvious here. I warned you I'm a
beginner.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140105/3535bb8e/attachment-0001.html>


More information about the Tutor mailing list