[Python-ideas] Proposing new file-like object methods

Wes Turner wes.turner at gmail.com
Mon Aug 1 20:27:44 EDT 2016


On Aug 1, 2016 7:13 PM, "Arek Bulski" <arek.bulski at gmail.com> wrote:
>
> I would like to see few methods added to file() objects:
>
>
>
> -          read(size, *, offset=None)  so os.pread() be used going around
file description position

https://docs.python.org/3/library/os.html#os.pread
(Unix)

file.pread?

>
> -          write(data, *, offset=None)  analog os.pwrite()

https://docs.python.org/3/library/os.html#os.pwrite
(Unix)

file.pwrite?

>
> -          flush(sync=False)  so os.fsync(f.fileno()) can optionally
follow

https://docs.python.org/3/library/os.html#os.fsync
(Unix, Windows)

file.fsync?

>
>
>
> For text files, offset would probably be not supported or count in
characters. New methods could be added like readp/writep/fsync instead of
modifying current methods, its debatable.

IDK how this works when wrapped with
https://docs.python.org/2/library/codecs.html#codecs.open ?

>
>
>
> Please tell me how to go about pushing this mainstream.

It's often easier to build a package with the new methods:
- e.g. https://pypi.python.org/pypi/backports/1.0
- https://pypi.python.org/pypi/pathlib/1.0.1

https://pypi.python.org/pypi/path.py

>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160801/e954e471/attachment.html>


More information about the Python-ideas mailing list