<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>creating lists based on parsed items</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hello all ...<BR>
<BR>
Sorry for jumping in and askig with 0 lurk-time.<BR>
<BR>
I am trying to do what (I think) should be fairly straightforward. I have a list of items that i want to sort into buckets. in item 1 of each line is the object I want to sort and in item 2 is the name of the bucket. I am making it dynamic however (so I don't know the bucket names in advance).<BR>
<BR>
I've spent a few hours in the archives and several sites (hate to consider my google search history against the term 'python' right now ... anyhoo ...) This is what I've pieced together so far.<BR>
<BR>
<BR>
       ## varName is the name of the bucket that I got out of the split line (comma separated)<BR>
       try:<BR>
            eval (varName + '.append("' + items[0] + '")')<BR>
        except NameError:<BR>
            ##print 'could not use ' + varName<BR>
            eval (varName + ' = []')<BR>
            print 'created ' + varName + 'as list'<BR>
       <BR>
        cmd2 = varName + '.append("' + items[0] + '")'<BR>
        print eval(cmd2)<BR>
<BR>
What I get back is:<BR>
<BR>
Traceback (most recent call last):<BR>
  File "./dict_2_slex.py", line 25, in ?<BR>
    eval (varName + ' = []')<BR>
  File "<string>", line 1<BR>
    noun = []<BR>
         ^<BR>
Any help for a python newb?!?<BR>
<BR>
TIA,<BR>
<BR>
Jason</FONT>
</P>

</BODY>
</HTML>