Re: [Tutor] Reading elements in a file

2011-05-05 Thread Prasad, Ramit
> string.capwords(s[, sep]) So capwords is a little bit different but you can use a combination of split() and title() to do some of it. Title() will work for the default case, but if you split on non-whitespace then you will need to manually use split(). 'test test test'.title() 'Test Test Test'

Re: [Tutor] Reading elements in a file

2011-05-05 Thread bob gailer
On 5/4/2011 6:59 PM, Alan Gauld wrote: The string methods are builtin and the string module is really only needed for backwatds compatibility these days. Yes, except for: 8.1.5. String functions The following functions are available to operate on string and Unicode objects. They are not avai

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Alan Gauld
"Jeff Peery" wrote Import sting Its lower case import and I've no idea what sting is! :-) If its meant to be string you don't need it. delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = string.split(line,delimiter) You don't need th

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Prasad, Ramit
May 04, 2011 2:35 PM To: Greg Christian; tutor@python.org Subject: Re: [Tutor] Reading elements in a file Greg, You might try… Import sting delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = string.split(line,delimiter)

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Jeff Peery
s@python.org] On Behalf Of Greg Christian Sent: Wednesday, May 04, 2011 11:38 AM To: tutor@python.org Subject: [Tutor] Reading elements in a file I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this”

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Steve Willoughby
On 04-May-11 11:40, Greg Christian wrote: Python version = 2.7.1 Platform = win32 I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” It depends on exactly how "just like" that example the file is.

[Tutor] Reading elements in a file

2011-05-04 Thread Greg Christian
Python version = 2.7.1 Platform = win32 I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” f = open('words.txt', "r") words = f.read() will read the whole file, is there a way to read just the

[Tutor] Reading elements in a file

2011-05-04 Thread Greg Christian
I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” f = open('words.txt', "r") words = f.read() will read the whole file, is there a way to read just the words: first word in that another part