[Python-Dev] Possible addition to itertools

Raymond Hettinger python at rcn.com
Thu Jun 24 02:49:06 EDT 2004



> -----Original Message-----
> > [Scott David Daniels]
> >> One feature that I'd find nice in itertools is access to "universal
> >> newlines" behavior.  This would make it much easier to extend
zipfile
> >> and other compression-related code to provide pseudo-files that
> > iterate
> >> properly.
> >

[Raymond]
> > My initial thoughts are:
> >
> > * the functionality is useful
> > * it duplicates some code from fileobject.c

[Bob]
> Which isn't available in pure Python anywhere, and isn't extensible
> enough to do what he wants to do.
> 
> > * unsure whether the needs to be Unicode aware
> 
> Universal newlines doesn't really make sense in the context of
unicode.
>   Unicode would definitely have another implementation, anyway
> (unicode.splitlines(...)).
> 
> FWIW, I've wanted to do things like this before..  but I think that
the
> universal newlines support in fileobject should just be refactored so
> that you can use it without a file object (possibly with a similar API
> to this).

I would support exposing this as a static function for the file type.
Alternately, I could see it going in the string module.


Raymond




More information about the Python-Dev mailing list