Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 2004 16:04:09 +0100 (BST)
From:      =?iso-8859-1?q?Max=20Russell?= <max_russell2000@yahoo.co.uk>
To:        Max Russell <max_russell2000@yahoo.co.uk>, freebsd-python@freebsd.org
Subject:   Re: Splitting elements on a line?
Message-ID:  <20040824150409.67240.qmail@web25406.mail.ukl.yahoo.com>
In-Reply-To: <20040824105814.36955.qmail@web25408.mail.ukl.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
P.S:
sorry about the whole "c:\" business. Protype is on
Windows. Boo Hiss.

 --- Max Russell <max_russell2000@yahoo.co.uk> wrote: 
> Hello-
> If I have a file made up of lines like this:
> 
> one two three
> four five six
> seven eight nine
> 
> how can I read the individual items into a lit, so
> that I do not get each list item consisting of
> something like:
> "one two three"
> 
> Currently I have this:
> import os, os.path, random
> filename = ("C:\list.txt")
> file = open(filename,"r")
> word_list = file.readlines()
> file.close()
> print word_list
> 
> # output from this program has format ['one two
> three\n', 'four five six']
> # therefore- need to split each item into individual
> compenents
> # also- need to remove whitespace and newline
> character
> 
> So:
> 
> Would I perform a split after all of the above?
> 
> Would I be better performing the split before
> reading
> the items into the list?
> 
> thanks
> Max
> 
> 
> 	
> 	
> 		
>
___________________________________________________________ALL-NEW
> Yahoo! Messenger - all new features - even more fun!
>  http://uk.messenger.yahoo.com
> _______________________________________________
> freebsd-python@freebsd.org mailing list
>
http://lists.freebsd.org/mailman/listinfo/freebsd-python
> To unsubscribe, send any mail to
> "freebsd-python-unsubscribe@freebsd.org"
>  


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040824150409.67240.qmail>