Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Kent Johnson said unto the world upon 28/12/05 07:06 AM: > Brian van den Broek wrote: > >>def punctuation_split(sequence): >> '''returns list of character sequences separating punctuation >>characters''' >> for mark in punctuation: >> sequence = sequence.replace(mark, ' %s ' %mark

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Kent Johnson wrote: > BTW thinking of writing this as a loop brings to mind some problems - > what will your program do with 'words' such as 555-1212 or "Ha!" ? Hmm, on reflection I don't thing "Ha!" will be a problem, but a 'word' with no letters will cause an IndexError. Your test for 4 lette

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Danny Yoo wrote: > Similarly, the try/except for IndexError seems too pervasive: rather than > wrap it around the whole program, we may want to limit its extent to just > around the sys.argv access. Otherwise, any other IndexError has the > potential of being misattributed. Much of the program do

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Brian van den Broek wrote: > def punctuation_split(sequence): > '''returns list of character sequences separating punctuation > characters''' > for mark in punctuation: > sequence = sequence.replace(mark, ' %s ' %mark) > return sequence.split(' ') You should look at re.spl

Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Eakin, W said unto the world upon 27/12/05 09:59 AM: > Hello, > Although I've been coding in PHP and ASP and JavaScript for a couple of > years now, I'm relatively new to Python. For learning exercises, I'm writing > small Python programs that do limited things, but hopefully do them well. > >

Re: [Tutor] code review please

2005-12-27 Thread Kent Johnson
Eakin, W wrote: > The code follows, so any comments and/or suggestions as to what I did > right or wrong, or what could be done better will be appreciated. > def fileScramble(fileName): > newFile = file('scrambled.txt', 'w') > newRow = '' > for line in fileName: > newRow = ''

Re: [Tutor] code review please

2005-12-27 Thread Danny Yoo
Hi William, Here are some constructive comments on the program; if you have questions on any of it, please feel free to ask. > def fileScramble(fileName): We may want to rename "fileName" to something else, as it isn't being treated as a filename, but more like a file-like object. Good names

[Tutor] code review please

2005-12-27 Thread Eakin, W
Hello,     Although I've been coding in PHP and ASP and _javascript_ for a couple of years now, I'm relatively new to Python. For learning exercises, I'm writing small Python programs that do limited things, but hopefully do them well. The following program takes a text file, reads through it, and