semi-Newbie question

len lsumnler at gmail.com
Sun Aug 13 12:16:49 EDT 2006


Sample and test code shows you are correct.

tpsFile - is really the SQL file I will be inserting new policy records
into

tagFile - is a CVS file containing all of the information for a new
policy in an XMLish fashion (one record per filed of the policy) I will
receive from a third party

tagIdxFile - is just a file that where the data from the tagFile should
be mapped into the tpsFile

CODE

tpsFile = {'tpsFirstName' : 'Kate', 'tpsLastName' : 'Sumner',
'tpsPhone': '532-1234'}
tagFile = {'tagname' : 'tagFirst', 'tagScope' : 'POL0', 'tagValue' :
'Rose'}
tagIdxFile = {'idxtagname' : 'tagFirst', 'idxtpsname' : 'tpsFirstName'}
print tpsFile['tpsFirstName']
tpsFile[tagIdxFile['idxtpsname']] = tagFile['tagValue']
print tpsFile['tpsFirstName']

RESULTS

>>>
Kate
Rose
>>>

Just a small note:  As trivial as this may seem this task was not
possible in the compiled language I work in due to the fact that there
was no way for me to get the data referenced by
tagIdxFile['idxtpsname'] and then use it as a field label on the left
side of the assignment statement because in the compiled language the
left side must be a label and NOT and expression.

Just strengthens my commitment to learn Python.


I would like to thank every one for their help, advice and patients.

Len Sumnler
Cameron Laird wrote:
> In article <1155268855.612545.108870 at h48g2000cwc.googlegroups.com>,
> len <lsumnler at gmail.com> wrote:
> 			.
> 			.
> 			.
> >I have done some more reading and I think the code I need is as
> >follows;
> >
> >mycode = "TagToSQL['mySQLfieldname'] = Tagfile['Value']"
> >exec mycode
> >
> >This is very new to me because I don't believe this can be done in a
> >compiled language or at least not as easily as in an interpeted
> >language like Python.
> >
> >I hope this clarifies the problem
> 			.
> 			.
> 			.
> I don't understand how
>
>   TagToSQL[mySQLfieldname] = Tagfile[Value]
>
> fails to meet requirements that
>
>   mycode = "TagToSQL['mySQLfieldname'] = Tagfile['Value']"
>   exec mycode
>
> satisfies.
>
> This thread confuses me.  Maybe you already have all the answers
> you seek.  If not, I recommend that you simplify--perhaps work
> through a single example datum in detail.  In the meantime, I
> applaud your judgment that you can achieve what you're after with
> table lookups and such rather than the thousand-way if-else at
> which you hinted at least once.




More information about the Python-list mailing list