[Tutor] creating variable names from string slices

noc bkd@graphnet.com
Tue Apr 1 03:35:03 2003

I have not been able to find the magic combination of keywords that will
guide me to the page for a recipe that shows me how to do this.

I'm telnetting to a mainframe, and capturing a screendump of data that's
neatly column formatted:

Betty     Blonde    Student
Veronica  Brunette  Student
Ginger    Redhead   Castaway
Maryann   Brunette  Castaway

What I want to do is define a function that gets passed each line, and
returns a dictionary with the first element  as the name, and the subsequent
elements as the key:value pairs:
(since the data is already in a nifty columnar form, I'll just be slicing
the elements out of the string)

Betty == {'haircolor':'Blonde', 'role':'Student'}
Veron == {'haircolor':'Brunett', 'role':'Student'}
Ginge == {'haircolor':'Redhea', 'role':'Castawa'}
Marya == {'haircolor':'Brunett', 'role':'Castawa'}

How do I make this trick work?