The newline (keyword) argument is passed to open() and the
TextIOWrapper() constructor. It only applies for text files. It deals
with how to handle line endings (sort of like universal newlines in
2.x). PEP 3116 also mentions it AFAIK.

--Guido

On 7/27/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote:
> What is the use of the keyword argument 'newline'? I tried to find
> where it's used to implement it in _stringio, but I have not found it
> in neither TextIOBase and TextIOWrapper.
>
> Thanks,
> -- Alexandre
>
> > Author: guido.van.rossum
> > Date: Fri Jul 27 20:03:11 2007
> > New Revision: 56587
> >
> > --- python/branches/py3k-struni/Lib/io.py       (original)
> > +++ python/branches/py3k-struni/Lib/io.py       Fri Jul 27 20:03:11 2007
> > @@ -1262,11 +1262,13 @@
> >
> >      # XXX This is really slow, but fully functional
> >
> > -    def __init__(self, initial_value=""):
> > -        super(StringIO, self).__init__(BytesIO(), "utf-8")
> > +    def __init__(self, initial_value="", encoding="utf-8", newline=None):
> > +        super(StringIO, self).__init__(BytesIO(),
> > +                                       encoding=encoding,
> > +                                       newline=newline)
> >          if initial_value:
> >              self.write(initial_value)
> >              self.seek(0)
> >
> >      def getvalue(self):
> > -        return self.buffer.getvalue().decode("utf-8")
> > +        return self.buffer.getvalue().decode(self._encoding)
> >
> _______________________________________________
> Python-3000-checkins mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to