[Tutor] put data from text file into list
Kent Johnson
kent37 at tds.net
Mon Jul 2 13:57:39 CEST 2007
Mike Hoy wrote:
> is it possible to take information contained inside a text file and put
> it into a list? My text file contains info derived from a list so it
> looks like this: ['foo','bar'].
If the file is Python syntax (including an assignment) you can import it
directly. Or try one of these recipes:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/281056
Kent
More information about the Tutor
mailing list