subscriber123 schrieb:
> On Apr 21, 8:58 am, Dustan <[EMAIL PROTECTED]> wrote:
>
>>>From my searches here, there is no equivalent to java's
>>
>>StringTokenizer in python, which seems like a real shame to me.
>>
>>However, str.split() works just as well, except for the fact that it
>>creates it all at one go. I suggest an itersplit be introduced for
>>lazy evaluation, if you don't want to take up recourses, and it could
>>be used just like java's StringTokenizer.
>>
>>Comments?
>
>
> That would be good, because then you could iterate over strings the
> same way that you iterate over files:
>
> for line in string.itersplit("\n"):
> ## for block ##
>
>
>>> block = """Hello world.
... This is a comment.
... With a few more lines."""
>>> for line in block.split("\n"):
... print line
...
Hello world.
This is a comment.
With a few more lines.
>>> for line in block.splitlines(): # could even use this one here
... print line
...
Hello world.
This is a comment.
With a few more lines.
Iterators would just speed up the whole thing and be more pythonic
(since development goes straight into the direction of converting all
and everything into iterators).
--
http://mail.python.org/mailman/listinfo/python-list