[issue37164] dict creation with converted zip objects produces inconsistent behavior

2019-06-05 Thread Dane Howard


Dane Howard  added the comment:

Yes, that seems to be it - in every case I was checking the value of c with 
`list(c)` and assuming that wouldn't change anything.

thanks!

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37164] dict creation with converted zip objects produces inconsistent behavior

2019-06-05 Thread Paul Moore


Paul Moore  added the comment:

Works fine for me:

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = ['1','2','3']
>>> b = [1,2,3]
>>> c = zip(a,b)
>>> print(dict(list(c)))
{'1': 1, '2': 2, '3': 3}
>>> print(dict(list(zip(a,b
{'1': 1, '2': 2, '3': 3}
>>> d = zip(b,a)
>>> print(dict(list(d)))
{1: '1', 2: '2', 3: '3'}

Are you sure you didn't try to use c twice? If you do, it will start up from 
where it left off (at the end) and so generate no further values:

>>> print(dict(list(c)))
{}

You need to remember that c is an iterator, and this is how iterators work. (If 
you're coming from Python 2, this is new behaviour in Python 3).

--
resolution:  -> not a bug

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37164] dict creation with converted zip objects produces inconsistent behavior

2019-06-05 Thread Dane Howard


New submission from Dane Howard :

confirmed on the following versions:
3.6.3 (Windows 10)
3.7.0 (Debian 9 & Windows 10)
3.7.1 (Debian 9)
a dictionary created with the dict() function will not always return the 
appropriate dictionary object. The following code produces the bug on all 
stated versions except 3.6.3/Win10, which exhibits slightly different behavior.

a = ['1','2','3']
b = [1,2,3]
c = zip(a,b)
print(dict(list(c))) #gives empty dict
print(dict(list(zip(a,b #gives {'1':1,'2':2,'3':3}
d = zip(b,a)
print(dict(list(d))) #gives {1:'1',':'2',3:'3'}

--
components: Windows
files: pybug.png
messages: 344729
nosy: Dane Howard, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: dict creation with converted zip objects produces inconsistent behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48394/pybug.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com