How about using eval ?
EDIT See @Ignacio answer with ast.literal_eval .
>>> c = eval("('item 1', [1,2,3,4] , [4,3,2,1])") >>> c ('item 1', [1, 2, 3, 4], [4, 3, 2, 1])
I would recommend doing this if you are 100% sure of the contents of the file.
>>> def myFunc(myString, myList1, myList2): ... print myString, myList1, myList2 ... >>> myFunc(*eval("('item 1', [1,2,3,4] , [4,3,2,1])")) item 1 [1, 2, 3, 4] [4, 3, 2, 1]
See @Ignacio's answer ... much, much safer.
Using ast will give:
>>> import ast >>> def myFunc(myString, myList1, myList2): ... print myString, myList1, myList2 ... >>> myFunc(*ast.literal_eval("('item 1', [1,2,3,4] , [4,3,2,1])")) item 1 [1, 2, 3, 4] [4, 3, 2, 1]