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.

classification
Title: results of `zip` are displayed as '
Type: Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, Sasha.Ovsankin, SilentGhost, eric.snow, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-05-29 16:20 by Sasha.Ovsankin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (10)
msg219348 - (view) Author: Sasha Ovsankin (Sasha.Ovsankin) Date: 2014-05-29 16:20
Python 3.4.0 (default, May 20 2014, 20:42:24)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> zip([1, 2, 3], ["a", "b", "c"])
<zip object at 0x1017c79c8>
>>>


Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> zip([1, 2, 3], ["a", "b", "c"])
[(1, 'a'), (2, 'b'), (3, 'c')]
msg219349 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2014-05-29 16:24
This is the correct behaviour. In python 3 zip returns an iterator. Detailed information is available in documentation. https://docs.python.org/3/library/functions.html#zip
msg219350 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-05-29 16:38
It may be the correct behavior but that doesn't mean we cannot update the repr to be more informative.  We've already done that for a number of types that previously used the default __repr__() implementation.  So in the case, how hard would it be to have the following repr?

>>> zip([1, 2, 3], ["a", "b", "c"])
zip([1, 2, 3], ["a", "b", "c"])
msg219351 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-29 17:03
"zip(<list_iterator object at 0xb70c7c8c>, <list_iterator object at 0xb70c7cac>)" doesn't look more readable to me.
msg219352 - (view) Author: Sasha Ovsankin (Sasha.Ovsankin) Date: 2014-05-29 17:08
It's also showing up in iPython. list(...) is a reasonable workaround but I disagree with the "not a bug" opinion. This is definitely the regression vs Python 2. Who else can I talk to about reopening this?
msg219354 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-05-29 17:54
> "zip(<list_iterator object at 0xb70c7c8c>, <list_iterator object at 0xb70c7cac>)" doesn't look more readable to me.

Well, that seems more informative to me.  Now you know that you're
zipping together two list iterators.  By "readable" do you mean
shorter?  In my opinion the size of a repr is less of a concern
(though not insignificant) than the usefulness of the information the
repr contains.  The fact that some objects (like list iterators) don't
themselves have informative reprs is an issue for any object with a
custom repr that reports it's attrs/args.
msg219357 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-05-29 18:50
How do you display the contents of an iterable without using them up, or have I grossly overlooked something?
msg219360 - (view) Author: Sasha Ovsankin (Sasha.Ovsankin) Date: 2014-05-29 19:16
>>> How do you display the contents of an iterable without using them up <<<

In general case you can't, but zip object _is_ reusable iterable so we can reuse it?
msg219362 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2014-05-29 19:36
>> How do you display the contents of an iterable without using them up
> In general case you can't, but zip object _is_ reusable iterable so we can reuse it?
I think you're misunderstanding what an iterator is or how it functions. Just to make it clear, it cannot be "reused". What Eric suggested, was to look at the inputs of zip and construct a representation of zip object that is more user friendly. The point that Serhiy's is making is that its usefulness is actually fairly limited.
msg219364 - (view) Author: Sasha Ovsankin (Sasha.Ovsankin) Date: 2014-05-29 20:36
Yep, you are right. Even the zip thingy is not reusable. Oh well...
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65806
2014-05-29 20:36:54Sasha.Ovsankinsetmessages: + msg219364
2014-05-29 19:36:47SilentGhostsetmessages: + msg219362
2014-05-29 19:16:59Sasha.Ovsankinsetmessages: + msg219360
2014-05-29 18:50:34BreamoreBoysetnosy: + BreamoreBoy
messages: + msg219357
2014-05-29 17:54:08eric.snowsetmessages: + msg219354
2014-05-29 17:08:21Sasha.Ovsankinsetmessages: + msg219352
2014-05-29 17:03:16serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg219351
2014-05-29 16:38:53eric.snowsetnosy: + eric.snow
messages: + msg219350
2014-05-29 16:24:35SilentGhostsetstatus: open -> closed

nosy: + SilentGhost
messages: + msg219349

resolution: not a bug
2014-05-29 16:20:10Sasha.Ovsankincreate