Re: [Tutor] Uniform 'for' behavior for strings and files

2008-06-11 Thread wesley chun
> for item in block: > > where block is a file, then item becomes each line of the file in turn > But if block in a large string (let's say the actual text that was in > the file), item becomes each character at a time. Is there a way to > have a uniform iteration irrespective of whether block is a

Re: [Tutor] Uniform 'for' behavior for strings and files

2008-06-09 Thread Shrutarshi Basu
Thanks for your suggestions, I've decided to go with the smart iterator solution, it's given me the results that I need. The generator solution also seems interesting and I might try it out at a later point. -- The ByteBaker : http://www.bytebaker.com ___

Re: [Tutor] Uniform 'for' behavior for strings and files

2008-06-09 Thread Alan Gauld
"Shrutarshi Basu" <[EMAIL PROTECTED]> wrote for item in block: where block is a file, then item becomes each line of the file in turn But if block in a large string (let's say the actual text that was in the file), item becomes each character at a time. Correct because for iterates over a

Re: [Tutor] Uniform 'for' behavior for strings and files

2008-06-09 Thread Kent Johnson
On Mon, Jun 9, 2008 at 5:26 PM, Shrutarshi Basu <[EMAIL PROTECTED]> wrote: > If I do the following: > > for item in block: > > where block is a file, then item becomes each line of the file in turn > But if block in a large string (let's say the actual text that was in > the file), item becomes eac

[Tutor] Uniform 'for' behavior for strings and files

2008-06-09 Thread Shrutarshi Basu
If I do the following: for item in block: where block is a file, then item becomes each line of the file in turn But if block in a large string (let's say the actual text that was in the file), item becomes each character at a time. Is there a way to have a uniform iteration irrespective of wheth