Hello all ... 

Sorry for jumping in and askig with 0 lurk-time.

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).

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.


       ## varName is the name of the bucket that I got out of the split line 
(comma separated)
       try:
            eval (varName + '.append("' + items[0] + '")')
        except NameError:
            ##print 'could not use ' + varName
            eval (varName + ' = []')
            print 'created ' + varName + 'as list'
        
        cmd2 = varName + '.append("' + items[0] + '")'
        print eval(cmd2)

What I get back is:

Traceback (most recent call last):
  File "./dict_2_slex.py", line 25, in ?
    eval (varName + ' = []')
  File "<string>", line 1
    noun = []
         ^ 
Any help for a python newb?!?

TIA,

Jason
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to