This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Implemented __str__ for zip and map objects
Type: enhancement Stage: resolved
Components: Versions: Python 3.9
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: AugPro, SilentGhost, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-05-15 09:02 by AugPro, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg342556 - (view) Author: Augustin PROLONGEAU (AugPro) Date: 2019-05-15 09:02
I think this would help development a lot.
Below an example of how i would see the function written for zip:

def __str__(self):
    return str((*self,))

# And for __repr__ function
def __repr__(self):
    return f'zip{str(self)}'
msg342557 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-05-15 09:08
This would exhaust the object, seems like a rather unfortunate side effect. I don't think this suggestion has any chance of being accepted, do feel free to take it to python-ideas to demonstrate that benefits outweigh the downsides.
msg342558 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-05-15 09:09
It will fail for infinite and very large iterables. It can cause performing unexpected operations. Examples:

    zip(itertools.count(), itertools.repeat(None))

    zip(file1, file2)

In general, the repr of the iterator should not change it state. But your proposition exhausts it.
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81104
2019-05-15 09:09:21serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg342558
2019-05-15 09:08:51SilentGhostsetstatus: open -> closed

nosy: + SilentGhost
messages: + msg342557

resolution: rejected
stage: resolved
2019-05-15 09:02:38AugProcreate