Re: [Tutor] writing list to new file

2005-02-14 Thread Alan Gauld
> If line.startswith('XXX'): > save list to new file > > But I get errors saying only stings can be saved this > way. You can save the list if the list can be printed, but its usually better to save the list contents. You will need to convert the contents into strings or else use

RE: [Tutor] writing list to new file

2005-02-13 Thread Tony Meyer
> I'm just trying to create a new file for all > the lines that startswith my string. So if my original > file looks like this: > > 1 Line 1 > 1 Line 2 > 2 Line 1 > 2 Line 2 > 3 Line 1 > 4 Line 1 > > I want to read in all the ones starting with 1 and > then save them to a new file. I can get the

RE: [Tutor] writing list to new file

2005-02-13 Thread Tony Meyer
> How would I save a list to a new file > > for example: > > If line.startswith('XXX'): > save list to new file > > But I get errors saying only stings can be saved this > way. What do you want to do with the file afterwards? If you want to load it back in as a list at some later