[issue34953] Implement `mmap.mmap.__repr__`

Ram Rachum report at bugs.python.org
Thu Oct 11 00:57:46 EDT 2018


Ram Rachum <ram at rachum.com> added the comment:

There are a few ways we can go with this, depending on how verbose we want to be and how willing we are to make calls to the data. Here are a few pieces of information we could expose:

 - Length
 - Whether it's a file or anonymous memory
 - The entire contents
 - The clipped contents
 - Whether it's opened or closed
 - The access type

So here's an example:

    <mmap.mmap object; length=514 access=ACCESS_READ>

And another: 

    <mmap.mmap object; length=514 content=b'This is my' ... b'file.'>

I don't know whether we're able to include the file name on there, that would be nice.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34953>
_______________________________________


More information about the Python-bugs-list mailing list